Index: /code/branches/network/CMakeLists.txt
===================================================================
--- /code/branches/network/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,109 @@
+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)
+  SET(Boost_INCLUDE_DIR "/usr/include/boost")
+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 #################
+
+#Performs the search and sets the variables
+FIND_PACKAGE(OGRE)
+#FIND_PACKAGE(OIS)
+# FIND_PACKAGE(CEGUI)
+# FIND_PACKAGE(CEGUI_OGRE)
+FIND_PACKAGE(ENet)
+FIND_PACKAGE(Boost REQUIRED thread filesystem)
+#FIND_PACKAGE(Boost REQUIRED 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}
+#  ${OIS_LIB_DIR}
+#  ${CEGUI_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}
+#  ${OIS_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/network/Doxyfile
===================================================================
--- /code/branches/network/Doxyfile	(revision 1545)
+++ /code/branches/network/Doxyfile	(revision 1545)
@@ -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/network/INSTALL
===================================================================
--- /code/branches/network/INSTALL	(revision 1545)
+++ /code/branches/network/INSTALL	(revision 1545)
@@ -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/network/LICENSE
===================================================================
--- /code/branches/network/LICENSE	(revision 1545)
+++ /code/branches/network/LICENSE	(revision 1545)
@@ -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/network/README
===================================================================
--- /code/branches/network/README	(revision 1545)
+++ /code/branches/network/README	(revision 1545)
@@ -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/network/TODO
===================================================================
--- /code/branches/network/TODO	(revision 1545)
+++ /code/branches/network/TODO	(revision 1545)
@@ -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/network/bin/def_keybindings.ini
===================================================================
--- /code/branches/network/bin/def_keybindings.ini	(revision 1545)
+++ /code/branches/network/bin/def_keybindings.ini	(revision 1545)
@@ -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=toggleFPS
+KeyF2=toggleRenderTime
+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/network/bin/disco.txt
===================================================================
--- /code/branches/network/bin/disco.txt	(revision 1545)
+++ /code/branches/network/bin/disco.txt	(revision 1545)
@@ -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/network/bin/irc.tcl
===================================================================
--- /code/branches/network/bin/irc.tcl	(revision 1545)
+++ /code/branches/network/bin/irc.tcl	(revision 1545)
@@ -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/network/bin/levels/sample.oxw
===================================================================
--- /code/branches/network/bin/levels/sample.oxw	(revision 1545)
+++ /code/branches/network/bin/levels/sample.oxw	(revision 1545)
@@ -0,0 +1,49 @@
+ <!--audio>
+	<ambient>
+		<ogg src="allgorythm-lift_up" />
+		<ogg src="allgorythm-resonance_blaster" />
+		<ogg src="luke_grey_-_hypermode" />
+		<ogg src="task_horizon_-_menu1" />
+		<ogg src="tha_silent_partner_-_void" />
+	</ambient>
+  </audio--> 
+
+<Ambient colourvalue="0.1, 0.1, 0.1" />
+<Skybox src="Orxonox/Starbox" />
+<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
+<Model position="2000,0,0" scale="10" mesh="tomato.mesh" yawpitchroll="-40,30,0" rotationAxis="1,0,0" rotationRate="-30"/>
+<Model position="0,2000,0" scale="10" mesh="tomato.mesh" yawpitchroll="-50,60,0" rotationAxis="1,0,0" rotationRate="-30"/>
+<Model position="0,0,2000" scale="10" mesh="tomato.mesh" yawpitchroll="-50,-30,0" rotationAxis="1,0,0" rotationRate="-30"/>
+<Model position="10000,16000,0" scale="100" mesh="DuBall1.mesh"/>
+<Model position="11400,16000,0" scale="60" mesh="DuBall2.mesh"/>
+<NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
+<NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
+<NPC position="0,-100,500" scale="1" mesh="razor.mesh"/>
+<NPC position="0,-200,450" scale="1" mesh="razor.mesh"/>
+<NPC position="100,0,400" scale="1" mesh="razor.mesh"/>
+
+<!--Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" />
+<Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">
+  <attached>
+    <Model name="drone2" position="200,-100,-500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">
+      <attached>
+        <Model name="starship2" position="500,200,-500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" />
+      </attached>
+    </Model>
+  </attached>
+</Model-->
+
+<!--Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
+<Model position="-200,1000,500" scale="10" mesh="hoover_gear0.mesh" yawpitchroll="-90,-90,0" />
+<Model position="-200,1000,500" scale="10" mesh="hoover_gear1.mesh" yawpitchroll="-90,-90,0" />
+<Model position="-200,1000,500" scale="10" mesh="hoover_gear2.mesh" yawpitchroll="-90,-90,0" />
+<Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" /-->
+
+
+<?lua
+for i = 1, 226, 1 
+do ?>
+  <Model position="<?lua print(math.random(-19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" />
+<?lua 
+end
+?>
Index: /code/branches/network/bin/ogre.cfg-init
===================================================================
--- /code/branches/network/bin/ogre.cfg-init	(revision 1545)
+++ /code/branches/network/bin/ogre.cfg-init	(revision 1545)
@@ -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/network/bin/orxonox.bat
===================================================================
--- /code/branches/network/bin/orxonox.bat	(revision 1545)
+++ /code/branches/network/bin/orxonox.bat	(revision 1545)
@@ -0,0 +1,4 @@
+title Orxonox
+path lib;%path%
+orxonox.exe
+pause
Index: /code/branches/network/bin/plugins.cfg-init
===================================================================
--- /code/branches/network/bin/plugins.cfg-init	(revision 1545)
+++ /code/branches/network/bin/plugins.cfg-init	(revision 1545)
@@ -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/network/bin/remote.tcl
===================================================================
--- /code/branches/network/bin/remote.tcl	(revision 1545)
+++ /code/branches/network/bin/remote.tcl	(revision 1545)
@@ -0,0 +1,2 @@
+set telnetserverthreadid [TclThreadManager create]
+TclThreadManager execute $telnetserverthreadid source telnet_server.tcl
Index: /code/branches/network/bin/run-script
===================================================================
--- /code/branches/network/bin/run-script	(revision 1545)
+++ /code/branches/network/bin/run-script	(revision 1545)
@@ -0,0 +1,25 @@
+#!/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" EXIT HUP INT TERM ABRT KILL
+exec ./orxonox $@
Index: /code/branches/network/bin/telnet_server.tcl
===================================================================
--- /code/branches/network/bin/telnet_server.tcl	(revision 1545)
+++ /code/branches/network/bin/telnet_server.tcl	(revision 1545)
@@ -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/network/cmake/CheckTardis.cmake
===================================================================
--- /code/branches/network/cmake/CheckTardis.cmake	(revision 1545)
+++ /code/branches/network/cmake/CheckTardis.cmake	(revision 1545)
@@ -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/network/cmake/FindALUT.cmake
===================================================================
--- /code/branches/network/cmake/FindALUT.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindALUT.cmake	(revision 1545)
@@ -0,0 +1,90 @@
+# - 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.
+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)
+  SET(ALUT_FOUND "YES")
+	MESSAGE(STATUS "FreeAlut was found")
+ENDIF(ALUT_LIBRARY)
+
+
Index: /code/branches/network/cmake/FindBoost.cmake
===================================================================
--- /code/branches/network/cmake/FindBoost.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindBoost.cmake	(revision 1545)
@@ -0,0 +1,302 @@
+# 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
+#
+# - 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})
+#
+# In Windows, we make the assumption that, if the Boost files are installed, the default directory
+# will be C:\boost.
+
+#
+# TODO:
+#
+# 1) Automatically find the Boost library files and eliminate the need
+#    to use Link Directories.
+#
+
+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. E.g /usr/local/include/boost-1_33_1 or c:\\boost\\include\\boost-1_33_1")
+
+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)
+
+IF(WIN32)
+  SET(BOOST_DIR_SEARCH
+    ${BOOST_DIR_SEARCH}
+    C:/boost/include
+    D:/boost/include
+  )
+ENDIF(WIN32)
+
+# 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.
+#
+IF(WIN32)
+  SET(Boost_INCLUDE_DIR
+#    ../libs/boost_1_33_1
+    ../libs/boost_1_34_1
+#    ../libs/boost_1_35_0
+  )
+ELSE(WIN32)
+  FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS
+
+# Look in other places.
+    ${BOOST_DIR_SEARCH}
+
+# Help the user find it if we cannot.
+    DOC "The ${BOOST_INCLUDE_PATH_DESCRIPTION}"
+  )
+ENDIF(WIN32)
+
+# 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)
+    MESSAGE(STATUS "sdfds")
+    IF(NOT Boost_FIND_QUIETLY)
+      MESSAGE(STATUS "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})
+    BOOST_FIND_LIBRARY(${library})
+    IF(Boost_${library}_FOUND)
+      SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${library}_LIBRARIES})
+      MESSAGE(STATUS "Found BoostLibrary: ${library}")
+    ENDIF(Boost_${library}_FOUND)
+  ENDFOREACH(library)
+ENDIF(Boost_LIBRARY_DIRS)
+
+IF(NOT Boost_FOUND)
+  IF(NOT Boost_FIND_QUIETLY)
+    MESSAGE(STATUS "Boost was not found. ${BOOST_DIR_MESSAGE}")
+  ELSE(NOT Boost_FIND_QUIETLY)
+    IF(Boost_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
+    ENDIF(Boost_FIND_REQUIRED)
+  ENDIF(NOT Boost_FIND_QUIETLY)
+ENDIF(NOT Boost_FOUND)
Index: /code/branches/network/cmake/FindCEGUI.cmake
===================================================================
--- /code/branches/network/cmake/FindCEGUI.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindCEGUI.cmake	(revision 1545)
@@ -0,0 +1,56 @@
+# 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.
+
+IF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR)
+    SET(CEGUI_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR)
+
+IF (WIN32) #Windows
+    MESSAGE(STATUS "Looking for CEGUI")
+    SET(CEGUI_INCLUDE_DIR ../libs/ogre/Dependencies/include/CEGUI)
+    SET(CEGUI_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release/lib)
+    SET(CEGUI_LIBRARIES debug CEGUIBase_d optimized CEGUIBase)
+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 "")
+ENDIF (WIN32)
+
+#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 "")
+
+IF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES)
+    SET(CEGUI_FOUND TRUE)
+ENDIF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES)
+
+IF (CEGUI_FOUND)
+    IF (NOT CEGUI_FIND_QUIETLY)
+        MESSAGE(STATUS "  libraries : ${CEGUI_LIBRARIES} from ${CEGUI_LIB_DIR}")
+        MESSAGE(STATUS "  includes  : ${CEGUI_INCLUDE_DIR}")
+    ENDIF (NOT CEGUI_FIND_QUIETLY)
+ELSE (CEGUI_FOUND)
+    IF (CEGUI_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find CEGUI")
+    ENDIF (CEGUI_FIND_REQUIRED)
+ENDIF (CEGUI_FOUND)
Index: /code/branches/network/cmake/FindCEGUI_OGRE.cmake
===================================================================
--- /code/branches/network/cmake/FindCEGUI_OGRE.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindCEGUI_OGRE.cmake	(revision 1545)
@@ -0,0 +1,56 @@
+# 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.
+
+IF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR)
+    SET(CEGUI_OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_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)
+    SET(CEGUI_OGRE_FOUND TRUE)
+ENDIF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES)
+
+IF (CEGUI_OGRE_FOUND)
+    IF (NOT CEGUI_OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "  libraries : ${CEGUI_OGRE_LIBRARIES} from ${CEGUI_OGRE_LIB_DIR}")
+        MESSAGE(STATUS "  includes  : ${CEGUI_OGRE_INCLUDE_DIR}")
+    ENDIF (NOT CEGUI_OGRE_FIND_QUIETLY)
+ELSE (CEGUI_OGRE_FOUND)
+    IF (CEGUI_OGRE_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find CEGUI_OGRE")
+    ENDIF (CEGUI_OGRE_FIND_REQUIRED)
+ENDIF (CEGUI_OGRE_FOUND)
Index: /code/branches/network/cmake/FindDirectX.cmake
===================================================================
--- /code/branches/network/cmake/FindDirectX.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindDirectX.cmake	(revision 1545)
@@ -0,0 +1,34 @@
+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
+
+  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 "Found DirectX")
+    endif (NOT DirectX_FIND_QUIETLY)
+  else (DirectX_FOUND)
+    if (DirectX_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find DirectX")
+    else (DirectX_FOUNC)
+      message(STATUS "Could not find DirectX")
+    endif (DirectX_FIND_REQUIRED)
+  endif (DirectX_FOUND)
+ENDIF(WIN32)
Index: /code/branches/network/cmake/FindENet.cmake
===================================================================
--- /code/branches/network/cmake/FindENet.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindENet.cmake	(revision 1545)
@@ -0,0 +1,53 @@
+# - 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/
+#
+
+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
+    )
+
+IF(WIN32)
+  SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
+  SET(ENet_LIBRARY ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
+ENDIF(WIN32)
+
+IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+    SET(ENET_FOUND TRUE)
+    SET(ENET_INCLUDE_DIR ${ENet_INCLUDE_DIR})
+    SET(ENET_LIBRARIES ${ENet_LIBRARY})
+ELSE (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+    SET(ENET_FOUND FALSE)
+ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+
+IF (ENET_FOUND)
+    IF (NOT ENet_FIND_QUIETLY)
+        MESSAGE(STATUS "Found enet: ${ENet_LIBRARY}")
+    ENDIF (NOT ENet_FIND_QUIETLY)
+ELSE (ENET_FOUND)
+    IF (ENet_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could NOT find enet")
+    ENDIF (ENet_FIND_REQUIRED)
+ENDIF (ENET_FOUND)
+
+MARK_AS_ADVANCED(ENet_INCLUDE_DIR ENet_LIBRARY)
Index: /code/branches/network/cmake/FindLua.cmake
===================================================================
--- /code/branches/network/cmake/FindLua.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindLua.cmake	(revision 1545)
@@ -0,0 +1,74 @@
+#  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
+
+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/src)
+
+  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 "")
+
+  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 "")
+
+  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+	
+
+  IF (Lua_FOUND)
+    MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
+  ELSE (Lua_FOUND)
+    IF (Lua_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find Lua")
+    ENDIF (Lua_FIND_REQUIRED)
+  ENDIF (Lua_FOUND)
+
+ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
Index: /code/branches/network/cmake/FindODE.cmake
===================================================================
--- /code/branches/network/cmake/FindODE.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindODE.cmake	(revision 1545)
@@ -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/network/cmake/FindOGRE.cmake
===================================================================
--- /code/branches/network/cmake/FindOGRE.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindOGRE.cmake	(revision 1545)
@@ -0,0 +1,52 @@
+# 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.
+
+IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR)
+    SET(OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR)
+
+IF (WIN32) #Windows
+    MESSAGE(STATUS "Looking for OGRE")
+    SET(OGRE_INCLUDE_DIR ../libs/ogre/OgreMain/include)
+    SET(OGRE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release)
+    SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain)
+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} CACHE STRING "")
+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)
+    SET(OGRE_FOUND TRUE)
+ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES)
+
+IF (OGRE_FOUND)
+    IF (NOT OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "  libraries : ${OGRE_LIBRARIES} from ${OGRE_LIB_DIR}")
+        MESSAGE(STATUS "  includes  : ${OGRE_INCLUDE_DIR}")
+    ENDIF (NOT OGRE_FIND_QUIETLY)
+ELSE (OGRE_FOUND)
+    IF (OGRE_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find OGRE")
+    ENDIF (OGRE_FIND_REQUIRED)
+ENDIF (OGRE_FOUND)
Index: /code/branches/network/cmake/FindOIS.cmake
===================================================================
--- /code/branches/network/cmake/FindOIS.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindOIS.cmake	(revision 1545)
@@ -0,0 +1,56 @@
+# Find OIS includes and library
+#
+# This module defines
+#  OIS_INCLUDE_DIR
+#  OIS_LIBRARIES, the libraries to link against to use OIS.
+#  OIS_LIB_DIR, the location of the libraries
+#  OIS_FOUND, If false, do not try to use OIS
+#
+# Created by Matt Williams to find OGRE libraries
+# Copyright © 2007, Matt Williams
+#
+# Modified by Nicolas Schlumberger to find OIS 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.
+
+IF (OIS_LIBRARIES AND OIS_INCLUDE_DIR)
+    SET(OIS_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (OIS_LIBRARIES AND OIS_INCLUDE_DIR)
+
+IF (WIN32) #Windows
+    MESSAGE(STATUS "Looking for OIS")
+    SET(OIS_INCLUDE_DIR ../libs/ogre/Dependencies/include)
+    SET(OIS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release)
+    SET(OIS_LIBRARIES debug OIS_d optimized OIS)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(OIS OIS /usr/pack/ois-1.0-sd/i686-debian-linux3.1/lib/pkgconfig/OIS.pc) # tardis specific hack
+    SET(OIS_INCLUDE_DIR ${OIS_INCLUDE_DIRS})
+    SET(OIS_LIB_DIR ${OIS_LIBDIR})
+    SET(OIS_LIBRARIES ${OIS_LIBRARIES} CACHE STRING "")
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(OIS_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(OIS_LIBRARIES)
+
+SET(OIS_INCLUDE_DIR ${OIS_INCLUDE_DIR} CACHE PATH "")
+SET(OIS_LIBRARIES ${OIS_LIBRARIES} CACHE STRING "")
+SET(OIS_LIB_DIR ${OIS_LIB_DIR} CACHE PATH "")
+
+IF (OIS_INCLUDE_DIR AND OIS_LIBRARIES)
+    SET(OIS_FOUND TRUE)
+ENDIF (OIS_INCLUDE_DIR AND OIS_LIBRARIES)
+
+IF (OIS_FOUND)
+    IF (NOT OIS_FIND_QUIETLY)
+        MESSAGE(STATUS "  libraries : ${OIS_LIBRARIES} from ${OIS_LIB_DIR}")
+        MESSAGE(STATUS "  includes  : ${OIS_INCLUDE_DIR}")
+    ENDIF (NOT OIS_FIND_QUIETLY)
+ELSE (OIS_FOUND)
+    IF (OIS_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find OIS")
+    ENDIF (OIS_FIND_REQUIRED)
+ENDIF (OIS_FOUND)
Index: /code/branches/network/cmake/FindOggVorbis.cmake
===================================================================
--- /code/branches/network/cmake/FindOggVorbis.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindOggVorbis.cmake	(revision 1545)
@@ -0,0 +1,101 @@
+
+#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_LIBRARY)
+  SET(OGG_FOUND "YES")
+	MESSAGE(STATUS "Ogg was found.")
+ENDIF(OGG_LIBRARY)
+
+SET(VORBIS_FOUND "NO")
+IF(VORBIS_LIBRARY)
+  SET(VORBIS_FOUND "YES")
+	MESSAGE(STATUS "Vorbis was found.")
+ENDIF(VORBIS_LIBRARY)
+
Index: /code/branches/network/cmake/FindOpenAL.cmake
===================================================================
--- /code/branches/network/cmake/FindOpenAL.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindOpenAL.cmake	(revision 1545)
@@ -0,0 +1,90 @@
+# - 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.
+#
+
+# 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)
+  SET(OPENAL_FOUND "YES")
+	MESSAGE(STATUS "OpenAL was found.")
+ENDIF(OPENAL_LIBRARY)
+
+
Index: /code/branches/network/cmake/FindPkgConfig.cmake
===================================================================
--- /code/branches/network/cmake/FindPkgConfig.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindPkgConfig.cmake	(revision 1545)
@@ -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/network/cmake/FindTCL.cmake
===================================================================
--- /code/branches/network/cmake/FindTCL.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindTCL.cmake	(revision 1545)
@@ -0,0 +1,171 @@
+# - 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_STUB_LIBRARY   = path to Tcl stub library
+#  TCL_STUB_LIBRARY_DEBUG = path to debug stub library
+#  TCL_INCLUDE_PATH   = path to where tcl.h can be found
+#  TCL_TCLSH          = path to tclsh binary (tcl tcl80)
+#  TK_LIBRARY         = path to Tk library (tk tk80 etc)
+#  TK_LIBRARY_DEBUG   = path to Tk library (debug)
+#  TK_STUB_LIBRARY    = path to Tk stub library
+#  TK_STUB_LIBRARY_DEBUG = path to debug Tk stub library
+#  TK_INCLUDE_PATH    = path to where tk.h can be found
+#  TK_INTERNAL_PATH   = path to where tkWinInt.h is found
+#  TK_WISH            = full path to the wish executable
+
+INCLUDE(CMakeFindFrameworks)
+INCLUDE(FindTclsh)
+INCLUDE(FindWish)
+
+GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
+GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" 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.4;Root]/lib
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;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 tcl83 tcl8.3 tcl82 tcl8.2 tcl80 tcl8.0
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TCL_LIBRARY_DEBUG
+  NAMES tcld tcl85d tcl8.5d tcl84d tcl8.4d tcl83d tcl8.3d tcl82d tcl8.2d tcl80d tcl8.0d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TCL_STUB_LIBRARY
+  NAMES tclstub tclstub84 tclstub8.4 tclstub83 tclstub8.3 tclstub82 tclstub8.2 tclstub80 tclstub8.0
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TCL_STUB_LIBRARY_DEBUG
+  NAMES tclstubd tclstub84d tclstub8.4d tclstub83d tclstub8.3d tclstub82d tclstub8.2d tclstub80d tclstub8.0d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TK_LIBRARY 
+  NAMES tk tk84 tk8.4 tk83 tk8.3 tk82 tk8.2 tk80 tk8.0
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TK_LIBRARY_DEBUG
+  NAMES tkd tk84d tk8.4d tk83d tk8.3d tk82d tk8.2d tk80d tk8.0d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TK_STUB_LIBRARY 
+  NAMES tkstub tkstub84 tkstub8.4 tkstub83 tkstub8.3 tkstub82 tkstub8.2 tkstub80 tkstub8.0
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TK_STUB_LIBRARY_DEBUG
+  NAMES tkstubd tkstub84d tkstub8.4d tkstub83d tkstub8.3d tkstub82d tkstub8.2d tkstub80d tkstub8.0d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+CMAKE_FIND_FRAMEWORKS(Tcl)
+CMAKE_FIND_FRAMEWORKS(Tk)
+
+SET(TCL_FRAMEWORK_INCLUDES)
+IF(Tcl_FRAMEWORKS)
+  IF(NOT TCL_INCLUDE_PATH)
+    FOREACH(dir ${Tcl_FRAMEWORKS})
+      SET(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
+    ENDFOREACH(dir)
+  ENDIF(NOT TCL_INCLUDE_PATH)
+ENDIF(Tcl_FRAMEWORKS)
+
+SET(TK_FRAMEWORK_INCLUDES)
+IF(Tk_FRAMEWORKS)
+  IF(NOT TK_INCLUDE_PATH)
+    FOREACH(dir ${Tk_FRAMEWORKS})
+      SET(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
+        ${dir}/Headers ${dir}/PrivateHeaders)
+    ENDFOREACH(dir)
+  ENDIF(NOT TK_INCLUDE_PATH)
+ENDIF(Tk_FRAMEWORKS)
+
+GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
+GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
+
+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.4;Root]/include
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include
+  "$ENV{ProgramFiles}/Tcl/include"
+  "C:/Program Files/Tcl/include"
+  C:/Tcl/include
+  /usr/include
+  /usr/local/include
+  /usr/include/tcl8.4
+  /usr/include/tcl8.3
+  /usr/include/tcl8.2
+  /usr/include/tcl8.0
+  ../libs/tcl8.5.2/generic
+)
+
+FIND_PATH(TCL_INCLUDE_PATH tcl.h
+  ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+)
+
+FIND_PATH(TK_INCLUDE_PATH tk.h
+  ${TK_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+)
+
+IF (WIN32)
+  FIND_PATH(TK_INTERNAL_PATH tkWinInt.h
+    ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+  )
+  MARK_AS_ADVANCED(TK_INTERNAL_PATH)
+ENDIF(WIN32)
+
+MARK_AS_ADVANCED(
+    TCL_TCLSH_PATH
+    TK_WISH_PATH
+    TCL_INCLUDE_PATH
+    TK_INCLUDE_PATH
+    TCL_LIBRARY
+    TCL_LIBRARY_DEBUG
+    TK_LIBRARY  
+    TK_LIBRARY_DEBUG
+  TCL_STUB_LIBRARY
+  TCL_STUB_LIBRARY_DEBUG
+  TK_STUB_LIBRARY  
+  TK_STUB_LIBRARY
+  TK_STUB_LIBRARY_DEBUG
+  )
+
+IF(TCL_INCLUDE_PATH)
+  IF(TK_INCLUDE_PATH)
+    IF(TCL_LIBRARY)
+      IF(TK_LIBRARY)
+        SET(TCL_FOUND 1)
+      ENDIF(TK_LIBRARY)
+    ENDIF(TCL_LIBRARY)
+  ENDIF(TK_INCLUDE_PATH)
+ENDIF(TCL_INCLUDE_PATH)
Index: /code/branches/network/cmake/FindZLIB.cmake
===================================================================
--- /code/branches/network/cmake/FindZLIB.cmake	(revision 1545)
+++ /code/branches/network/cmake/FindZLIB.cmake	(revision 1545)
@@ -0,0 +1,74 @@
+# - Find zlib
+# Find the native ZLIB includes and library
+#
+#  ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
+#  ZLIB_LIBRARIES   - 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
+#
+
+IF(UNIX)
+  IF (ZLIB_INCLUDE_DIR)
+  # Already in cache, be silent
+    SET(ZLIB_FIND_QUIETLY TRUE)
+  ENDIF (ZLIB_INCLUDE_DIR)
+
+  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
+  )
+
+  IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+    SET(ZLIB_FOUND TRUE)
+      SET( ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
+  ELSE (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+    SET(ZLIB_FOUND FALSE)
+    SET( ZLIB_LIBRARIES )
+  ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+
+  IF (ZLIB_FOUND)
+    IF (NOT ZLIB_FIND_QUIETLY)
+      MESSAGE(STATUS "Found ZLIB: ${ZLIB_LIBRARY}")
+    ENDIF (NOT ZLIB_FIND_QUIETLY)
+  ELSE (ZLIB_FOUND)
+    IF (ZLIB_FIND_REQUIRED)
+        MESSAGE(STATUS "Looked for Z libraries named ${ZLIBS_NAMES}.")
+        MESSAGE(FATAL_ERROR "Could NOT find z library")
+    ENDIF (ZLIB_FIND_REQUIRED)
+  ENDIF (ZLIB_FOUND)
+
+  MARK_AS_ADVANCED(
+    ZLIB_LIBRARY
+    ZLIB_INCLUDE_DIR
+  )
+ENDIF(UNIX)
+
+IF(WIN32)
+  IF(EXISTS "../libs/ogre/Dependencies/lib/Release")
+    SET (ZLIB_LIBRARY_DIR "../libs/ogre/Dependencies/lib/Release")
+  ENDIF(EXISTS "../libs/ogre/Dependencies/lib/Release")
+
+  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
+    ../libs/ogre/Dependencies/include
+  )
+
+  FIND_LIBRARY(ZLIB_LIBRARY
+    NAMES zlib
+    PATHS ${ZLIB_LIBRARY_DIR}
+  )
+
+  IF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
+    MESSAGE(STATUS "Zlib was found.")
+  ELSE(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
+    MESSAGE(FATAL_ERROR "Zlib was NOT found.")
+  ENDIF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
+ENDIF(WIN32)
Index: /code/branches/network/cmakeclearcache
===================================================================
--- /code/branches/network/cmakeclearcache	(revision 1545)
+++ /code/branches/network/cmakeclearcache	(revision 1545)
@@ -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/network/run
===================================================================
--- /code/branches/network/run	(revision 1545)
+++ /code/branches/network/run	(revision 1545)
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd bin
+./run-script $@
+cd ..
Index: /code/branches/network/src/CMakeLists.txt
===================================================================
--- /code/branches/network/src/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,15 @@
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(orxonox)
+INCLUDE_DIRECTORIES(tolua)
+INCLUDE_DIRECTORIES(ois)
+
+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/network/src/asylum/audio/_AudioObject.cc
===================================================================
--- /code/branches/network/src/asylum/audio/_AudioObject.cc	(revision 1545)
+++ /code/branches/network/src/asylum/audio/_AudioObject.cc	(revision 1545)
@@ -0,0 +1,142 @@
+/*
+*   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:
+*      ...
+*
+*/
+
+
+#include <iostream>
+#include <string>
+
+#include "core/Debug.h"
+#include "AudioObject.h"
+
+namespace audio
+{
+  AudioObject::AudioObject(std::string audioFile)
+  {
+    audioFile_ = audioFile;
+    SourcePos[0]=0;
+    SourcePos[1]=0;
+    SourcePos[2]=0;
+
+    SourceVel[0]=0;
+    SourceVel[1]=0;
+    SourceVel[2]=0;
+
+    ListenerPos[0]=0;
+    ListenerPos[1]=0;
+    ListenerPos[2]=0;
+
+    ListenerVel[0]=0;
+    ListenerVel[1]=0;
+    ListenerVel[2]=0;
+
+    ListenerOri[0]=0;
+    ListenerOri[1]=0;
+    ListenerOri[2]=-1;
+    ListenerOri[3]=0;
+    ListenerOri[4]=1;
+    ListenerOri[5]=0;
+
+
+    // Initialize OpenAL and clear the error bit.
+
+    alutInit(NULL, 0);
+    alGetError();
+
+    // Load the wav data.
+
+    if(LoadALData() == AL_FALSE)
+    {
+      printf("Error loading sound data.");
+
+    }
+
+    SetListenerValues();
+    COUT(3) << "Info: Play sone ambient background sound";
+  }
+
+  AudioObject::~AudioObject()
+  {
+    KillALData();
+  }
+
+  ALboolean AudioObject::LoadALData()
+  {
+    ALenum format;
+    ALsizei size;
+    ALvoid* data;
+    ALsizei freq;
+    ALboolean loop;
+
+
+    alGenBuffers(1, &Buffer);
+
+    if(alGetError() != AL_NO_ERROR)
+      return AL_FALSE;
+
+    alutLoadWAVFile((ALbyte*)audioFile_.c_str(), &format, &data, &size, &freq, &loop);
+    alBufferData(Buffer, format, data, size, freq);
+    alutUnloadWAV(format, data, size, freq);
+
+    alGenSources(1, &Source);
+
+    if(alGetError() != AL_NO_ERROR)
+      return AL_FALSE;
+
+    alSourcei (Source, AL_BUFFER,   Buffer   );
+    alSourcef (Source, AL_PITCH,    1.0      );
+    alSourcef (Source, AL_GAIN,     1.0      );
+    alSourcefv(Source, AL_POSITION, SourcePos);
+    alSourcefv(Source, AL_VELOCITY, SourceVel);
+    alSourcei (Source, AL_LOOPING,  loop     );
+
+    if(alGetError() == AL_NO_ERROR)
+      return AL_TRUE;
+
+
+    return AL_FALSE;
+  }
+
+  void AudioObject::SetListenerValues()
+  {
+    alListenerfv(AL_POSITION,    ListenerPos);
+    alListenerfv(AL_VELOCITY,    ListenerVel);
+    alListenerfv(AL_ORIENTATION, ListenerOri);
+  }
+
+  void AudioObject::KillALData()
+  {
+    alDeleteBuffers(1, &Buffer);
+    alDeleteSources(1, &Source);
+    alutExit();
+  }
+
+  void AudioObject::play()
+  {
+    alSourcePlay(Source);
+  }
+
+}
Index: /code/branches/network/src/asylum/core/InputEvent.h
===================================================================
--- /code/branches/network/src/asylum/core/InputEvent.h	(revision 1545)
+++ /code/branches/network/src/asylum/core/InputEvent.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEvent Structure declaration
+ */
+
+#ifndef _InputEvent_H__
+#define _InputEvent_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  struct InputEvent
+  {
+    unsigned char id;      //!< Event ID
+    bool bStarted;         //!< Tells whether the Event started or ended (e.g. firing started)
+    int data1, data2;      //!< Two additional integer datafields, for instance for the mouse moved event
+    void* dataRef;         //!< Additional pointer to any further data
+  };
+}
+
+#endif /* _InputEvent_H__ */
Index: /code/branches/network/src/asylum/core/InputEventListener.cc
===================================================================
--- /code/branches/network/src/asylum/core/InputEventListener.cc	(revision 1545)
+++ /code/branches/network/src/asylum/core/InputEventListener.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Core relevant parts of InputEventListener
+ */
+
+#include "InputEventListener.h"
+#include "CoreIncludes.h"
+
+namespace orxonox
+{
+  /**
+    @brief standard constructor
+  */
+  InputEventListener::InputEventListener()
+  {
+    RegisterRootObject(InputEventListener);
+    this->bActive_ = true;
+  }
+
+  InputEventListener::~InputEventListener()
+  {
+  }
+
+}
Index: /code/branches/network/src/asylum/core/InputEventListener.h
===================================================================
--- /code/branches/network/src/asylum/core/InputEventListener.h	(revision 1545)
+++ /code/branches/network/src/asylum/core/InputEventListener.h	(revision 1545)
@@ -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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEventListener Interface declaration
+ */
+
+#ifndef _InputEventListener_H__
+#define _InputEventListener_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  class _CoreExport InputEventListener : virtual public OrxonoxClass
+  {
+    friend class InputHandlerGame;
+  public:
+    InputEventListener();
+    virtual ~InputEventListener();
+    /** Method is called every time an Input event occurs && bActive */
+    virtual void eventOccured(InputEvent &evt) = 0;
+
+  private:
+    bool bActive_;
+  };
+}
+
+#endif /* _InputEventListener_H__ */
Index: /code/branches/network/src/asylum/loader/CMakeLists.txt
===================================================================
--- /code/branches/network/src/asylum/loader/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/asylum/loader/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,15 @@
+SET( LOADER_SRC_FILES
+  LevelLoader.cc
+)
+
+IF (WIN32)
+  ADD_LIBRARY( loader ${LOADER_SRC_FILES} )
+ELSE (WIN32)
+  ADD_LIBRARY( loader SHARED ${LOADER_SRC_FILES})
+ENDIF (WIN32)
+
+SET_TARGET_PROPERTIES( loader PROPERTIES LINK_FLAGS "--no-undefined" )
+
+TARGET_LINK_LIBRARIES( loader
+  util
+)
Index: /code/branches/network/src/asylum/loader/LevelLoader.cc
===================================================================
--- /code/branches/network/src/asylum/loader/LevelLoader.cc	(revision 1545)
+++ /code/branches/network/src/asylum/loader/LevelLoader.cc	(revision 1545)
@@ -0,0 +1,213 @@
+/*
+*   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:
+*     Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+*   Co-authors:
+*      ...
+*
+*/
+
+#include "OrxonoxStableHeaders.h"
+
+#include <OgreOverlay.h>
+#include <OgreOverlayManager.h>
+
+#include "core/Error.h"
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+
+#include "audio/AudioManager.h"
+#include "core/BaseObject.h"
+#include "orxonox/Orxonox.h"
+
+#include "LevelLoader.h"
+
+namespace loader
+{
+
+  LevelLoader::LevelLoader(std::string file, std::string path)
+  {
+    valid_ = false;
+
+    // Load XML level file
+    path.append("/");
+    path.append(file);
+
+    // Open xml file
+    doc_.LoadFile(path.c_str());
+
+    // Check if file was loaded
+    if (doc_.LoadFile())
+    {
+      TiXmlHandle hDoc(&doc_);
+      TiXmlHandle hRoot(0);
+      TiXmlElement* pElem;
+
+      // Check for root element
+      pElem = hDoc.FirstChildElement("orxonoxworld").Element();
+      if (pElem)
+      {
+        // Set root element
+        hRoot = TiXmlHandle(pElem);
+        rootElement_ = hRoot.Element();
+
+        // Set level description
+        pElem = hRoot.FirstChild("description").Element();
+        if (pElem)
+        {
+          description_ = pElem->GetText();
+        }
+
+        // Set level name
+        name_ = rootElement_->Attribute("name");
+        image_ = rootElement_->Attribute("image");
+
+        valid_ = true;
+      }
+      else
+      {
+        orxonox::Error("Level file has no valid root node");
+      }
+    }
+    else
+    {
+      orxonox::Error("Could not load level file ");
+    }
+  }
+
+  void LevelLoader::loadLevel()
+  {
+    if (valid_)
+    {
+      TiXmlElement* loadElem;
+      TiXmlElement* audioElem;
+      TiXmlElement* worldElem;
+      TiXmlElement* tElem;
+      TiXmlNode* tNode;
+
+      Ogre::OverlayManager& omgr = Ogre::OverlayManager::getSingleton();
+      Ogre::Overlay* mLoadOverlay; // FIXME: may be uninitialized
+
+      // Set loading screen
+      loadElem = rootElement_->FirstChildElement("loading");
+      if (loadElem)
+      {
+        // Set background
+        tElem = loadElem->FirstChildElement("background");
+        if (tElem)
+        {
+          loadingBackgroundColor_ = tElem->Attribute("color");
+          loadingBackgroundImage_ = tElem->Attribute("image");
+        }
+        // Set bar
+        tElem = loadElem->FirstChildElement("bar");
+        if (tElem)
+        {
+          loadingBarImage_ = tElem->Attribute("image");;
+          loadingBarTop_ = tElem->Attribute("top");
+          loadingBarLeft_ = tElem->Attribute("left");
+          loadingBarWidth_ = tElem->Attribute("width");
+          loadingBarHeight_ = tElem->Attribute("height");
+        }
+
+
+        mLoadOverlay = (Ogre::Overlay*)omgr.getByName("Orxonox/LoadingScreenSample");
+        mLoadOverlay->show();
+
+        COUT(0) << "This is Orxonox" << std::endl;
+        COUT(0) << "the hottest 3D action shooter ever to exist" << std::endl;
+        COUT(0) << "Level: " << name() << std::endl << "Description:" << description() << std::endl << "Image:" << image() << std::endl;
+        COUT(4) << "Backgroundcolor: " << loadingBackgroundColor_ << std::endl << "Backgroundimage:" << loadingBackgroundImage_ << std::endl;
+
+      }
+
+      // Load audio
+      audio::AudioManager* auMan = orxonox::Orxonox::getSingleton()->getAudioManagerPointer();
+      audioElem = rootElement_->FirstChildElement("audio");
+
+      if (audioElem)
+      {
+        audioElem = audioElem->FirstChildElement("ambient");
+        if (audioElem)
+        {
+          tNode = 0;
+          //FIXME something is wrong, probably missing ==
+          while( tNode = audioElem->IterateChildren( tNode ) )
+          {
+            if (tNode->Type() == TiXmlNode::ELEMENT)
+            {
+
+              tElem = tNode->ToElement();
+              std::string elemVal = tElem->Value();
+              if (elemVal == "ogg")
+              {
+                COUT(3) << "Adding sound "<< tElem->Attribute("src") << std::endl;
+
+                auMan->ambientAdd(tElem->Attribute("src"));
+              }
+            }
+          }
+          auMan->ambientStart();
+        }
+      }
+
+      // Load world
+      worldElem = rootElement_->FirstChildElement("world");
+      if (worldElem)
+      {
+        tNode = 0;
+        //FIXME something is wrong, probably missing ==
+        while (tNode = worldElem->IterateChildren(tNode))
+        {
+          if (tNode->Type() == TiXmlNode::ELEMENT)
+          {
+            tElem = tNode->ToElement();
+            orxonox::Identifier* id = ID(tElem->Value());
+            if (id)
+            {
+              orxonox::BaseObject* obj = id->fabricate();
+              obj->loadParams(tElem);
+            }
+            else
+            {
+              COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname." << std::endl;
+            }
+          }
+        }
+      }
+
+      if (loadElem)
+      {
+        // FIXME: check for potential initialisation of mLoadOverlay
+        mLoadOverlay->hide();
+      }
+
+
+      COUT(0) << "Loading finished!" << std::endl << std::endl;
+    }
+  }
+
+  LevelLoader::~LevelLoader()
+  {
+
+  }
+
+}
Index: /code/branches/network/src/asylum/loader/LevelLoader.h
===================================================================
--- /code/branches/network/src/asylum/loader/LevelLoader.h	(revision 1545)
+++ /code/branches/network/src/asylum/loader/LevelLoader.h	(revision 1545)
@@ -0,0 +1,57 @@
+/**
+* Orxonox - www.orxonox.net
+* Level Loader class
+*
+* @author Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+*/
+
+#ifndef _LevelLoader_H__
+#define _LevelLoader_H__
+
+#include <string>
+
+#include "LoaderPrereqs.h"
+#include "util/tinyxml/tinyxml.h"
+
+class TiXmlDocument;   // Forward declaration
+class TiXmlElement;    // Forward declaration
+
+namespace loader
+{
+  class _LoaderExport LevelLoader
+  {
+  public:
+    // Constructors, loads the level file and some information data
+    LevelLoader(std::string file, std::string dir = "levels");
+    // Destructor
+    virtual ~LevelLoader();
+    // Loads all level data
+    void loadLevel();
+
+    // Getters
+    inline std::string name() {return name_; };
+    inline std::string description() {return description_; };
+    inline std::string image() {return image_; };
+  private:
+    //! Level information
+    std::string name_;
+    std::string description_;
+    std::string image_;
+    std::string loadingBackgroundColor_;
+    std::string loadingBackgroundImage_;
+    std::string loadingBarImage_;
+    std::string loadingBarTop_;
+    std::string loadingBarLeft_;
+    std::string loadingBarWidth_;
+    std::string loadingBarHeight_;
+
+    //! Set to true if it was possible to load the level file
+    bool valid_;
+
+    // Xml-Stuff
+    TiXmlDocument doc_;
+    TiXmlElement *rootElement_;
+  };
+}
+
+#endif /* _LevelLoader_H__ */
Index: /code/branches/network/src/asylum/loader/LoaderPrereqs.h
===================================================================
--- /code/branches/network/src/asylum/loader/LoaderPrereqs.h	(revision 1545)
+++ /code/branches/network/src/asylum/loader/LoaderPrereqs.h	(revision 1545)
@@ -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  OrxonoxPrereq.cc
+ @brief Contains all the necessary forward declarations for all classes, structs and enums.
+ */
+
+#ifndef _LoaderPrereqs_H__
+#define _LoaderPrereqs_H__
+
+#include "orxonox/OrxonoxPlatform.h"
+
+// Compile loader directly in orxonox executable, if on Visual Studio platform
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(ORXONOX_SHARED_BUILD)
+#  define LOADER_SHARED_BUILD
+#endif
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( LOADER_STATIC_BUILD )
+#  ifdef LOADER_SHARED_BUILD
+#    define _LoaderExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _LoaderExport
+#    else
+#      define _LoaderExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _LoaderExport  __attribute__ ((visibility("default")))
+#else
+#  define _LoaderExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace loader {
+  class LevelLoader;
+}
+
+#endif /* _LoaderPrereqs_H__ */
Index: /code/branches/network/src/asylum/network/NetworkFrameListener.h
===================================================================
--- /code/branches/network/src/asylum/network/NetworkFrameListener.h	(revision 1545)
+++ /code/branches/network/src/asylum/network/NetworkFrameListener.h	(revision 1545)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: NetworkFrameListener
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _NetworkFrameListener_H__
+#define _NetworkFrameListener_H__
+
+#include "NetworkPrereqs.h"
+
+#include <OgreFrameListener.h>
+
+#include "Server.h"
+#include "Client.h"
+
+network::Server *server_g;
+network::Client *client_g;
+
+namespace network
+{
+  class ServerFrameListener : public Ogre::FrameListener{
+  private:
+    bool frameStarted(const Ogre::FrameEvent &evt){
+      server_g->tick(evt.timeSinceLastFrame);
+      return FrameListener::frameStarted(evt);
+    }
+  };
+
+  class ClientFrameListener : public Ogre::FrameListener{
+  private:
+    bool frameStarted(const Ogre::FrameEvent &evt){
+      //std::cout << "framelistener" << std::endl;
+      client_g->tick(evt.timeSinceLastFrame);
+      return FrameListener::frameStarted(evt);
+    }
+  };
+
+
+
+
+}
+
+#endif /* _NetworkFrameListener_H__ */
Index: /code/branches/network/src/asylum/network/PacketBufferTestExt.cc
===================================================================
--- /code/branches/network/src/asylum/network/PacketBufferTestExt.cc	(revision 1545)
+++ /code/branches/network/src/asylum/network/PacketBufferTestExt.cc	(revision 1545)
@@ -0,0 +1,81 @@
+/*
+*   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:
+*      ...
+*
+*/
+
+#include <string>
+#include <iostream>
+#include <enet/enet.h>
+#include <boost/thread/thread.hpp>
+
+#include "util/Sleep.h"
+#include "PacketBuffer.h"
+#include "PacketBuffer.cc"
+
+using namespace network;
+
+void write(PacketBuffer *test){
+  ENetEvent event;
+  ENetPacket *packet;
+  if(test->isEmpty())
+    std::cout << "empty buffer" << 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;
+}
+
+
+int main(int argc, char **argv[]){
+  PacketBuffer test = PacketBuffer();
+  boost::thread thrd1(boost::bind(&write, &test));
+  boost::thread thrd2(boost::bind(&read, &test));
+
+  thrd1.join();
+  thrd2.join();
+
+  return 0;
+}
+
Index: /code/branches/network/src/asylum/orxonox/AIClass.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/AIClass.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/AIClass.h	(revision 1545)
@@ -0,0 +1,95 @@
+#ifndef _AIClass_H__
+#define _AIClass_H__
+
+#include "util/Vector3.h"
+
+namespace orxonox
+{
+  class AIPilot
+  {
+
+
+    /*
+    TASKS:                                                                         Requirements:
+
+    - Change actual Speed to required Speed                                          - Speed as Vector3 , spaceship(?) -> pilot attached to it or vice versa (?)
+    - Open fire, if allowed                                                          - Status of the fleet commander -> allowed to fire , fly etc.
+    - differ friend, ally and enemy                                                  - Lists of ships + who controls them
+    - report ship status to fleet commander                                          - Call own ship status -> ammo, damage etc.
+
+
+
+    */
+
+  public:
+    Vector3 speed;
+
+
+
+    //default constructor
+    AIPilot() {
+      speed = (1,0,0);
+    }
+
+    Vector3 steer(Vector3 reqSpeed) {
+      Quaternion sRotation = speed.getRotationTo(reqSpeed);
+      Radian rollarc = sRotation.getRoll();
+      Radian pitcharc = sRotation.getPitch();
+      Radian yawarc = sRotation.getYaw();
+      return Vector3((float)rollarc.valueRadians(), (float)pitcharc.valueRadians(), (float)yawarc.valueRadians());
+    }
+
+
+  };
+
+  class AIFleetCommander : public  AIPilot {
+
+
+    /*
+    TASKS:                                                                       Requirements:
+
+    - Same tasks as AI_Pilot (only if shipcontrol)                                   - Same as AI_Pilot
+    - Calculate required Speed for any ship in Fleet                                 - Knows all calculation functions
+    - Request fleet status and report to commander                                   - Better list of all ships -> more data for fleet ships
+
+
+
+    */
+
+  public:
+
+
+    //default constructor
+    AIFleetCommander() {
+
+    }
+
+
+
+  };
+
+  class AICommander : public  AIFleetCommander
+  {
+
+
+    /*
+    TASKS:                                                                     Requirements:
+
+    - Decide on general tactics                                                      - List of general fleet status + all possible information on enemies
+    - Save and load tactical data (?)                                                - files with tactical data, e.g. success of strategy etc.
+
+
+
+    */
+
+    //default constructor
+    AICommander() {
+
+    }
+
+
+  };
+
+}
+
+#endif /* _AIClass_H__ */
Index: /code/branches/network/src/asylum/orxonox/Arrival.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/Arrival.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/Arrival.h	(revision 1545)
@@ -0,0 +1,82 @@
+
+// Arrival Class
+
+
+#ifndef _Arrival_H__
+#define _Arrival_H__
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+  class Arrival
+  {
+  public:
+    Vector3 location;           //!< locationvector of the element
+    Vector3 speed;              //!< speedvector of the element
+    Vector3 acceleration;       //!< accelerationvector of the element
+    Vector3 target;             //!< target to arrive
+    int accelerationForwards;   //!< from steering-interface
+    int MaxSpeed;               //!< from steering-interface
+
+
+    Arrival() {
+      acceleration = (0,0,0);
+      speed = (0,0,0);
+      location = (0,0,0);
+      target = (0,0,0);
+    }
+
+    Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
+      acceleration = acceleration_;
+      speed = speed_;
+      location = location_;
+      target = target_;
+    }
+
+    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
+      acceleration = acceleration_;
+      speed = speed_;
+      location = location_;
+      target = target_;
+    }
+
+    void setTarget(Vector3 target_) {
+      setValues(this->location, this->speed, this->acceleration, target_);
+    }
+
+    Vector3 getDirection() {
+      Vector3 direction = target-location;
+    }
+
+    double relativeDirectApproach() {
+      // Maxspeed / accelerationForwards = time needed to break with max acceleration
+      // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 0
+      return (accelerationForwards / (2*getDirection().length() / ((MaxSpeed/accelerationForwards)*(MaxSpeed/accelerationForwards))) );
+    }
+
+    void Approach() {
+      Quaternion rotation = Quaternion(0,0,0,0);
+      if (relativeDirectApproach() > 1)
+      {
+        float length = speed.length();
+        speed = (speed+getDirection());
+        speed.normalise();
+        speed = speed*length;
+        if (relativeDirectApproach() > 4)
+        {
+          //accelerate
+        }
+        else
+        {
+          // speed will stay constant
+        }
+      }
+      else {
+      }
+    }
+
+  };
+}
+
+#endif /* _Arrival_H__ */
Index: /code/branches/network/src/asylum/orxonox/Flocking.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/Flocking.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/Flocking.h	(revision 1545)
@@ -0,0 +1,140 @@
+
+//Headerfile: Flocking.h
+
+#ifndef _Flocking_H__
+#define _Flocking_H__
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+  class Element // An element that flocks
+  {
+
+  public:
+    Vector3 location;                       //!< locationvector of the element
+    Vector3 speed;                          //!< speedvector of the element
+    Vector3 acceleration;                   //!< accelerationvector of the element
+    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
+    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 ANZELEMENTS = 9;             //!< number of elements
+
+    //! default constructor
+    Element() {
+      acceleration = Vector3(0,0,0);
+      speed = Vector3(0,0,0);
+      location = Vector3(0,0,0);
+      movable = true;
+    }
+
+    /** constructor
+    *  @param location_ sets locationvector of the element
+    *  @param speed_ sets speedvector of the element
+    *  @param acceleration_ sets accelerationvector of the element
+    *  @param movable_ sets movability of the element
+    */
+    Element(Vector3 location_, Vector3 speed_, Vector3 acceleration_, bool movable_) {
+      acceleration = acceleration_;
+      speed = speed_;
+      location = location_;
+      movable = movable_;
+    }
+
+    //! function to chance values of an element
+    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, bool movable_) {
+      acceleration = acceleration_;
+      speed = speed_;
+      location = location_;
+      movable = movable_;
+    }
+
+    /** calculates the distance between the element and an other point given by temp
+    * @param e remote object to calculate distance to
+    */
+    float getDistance(Element e) {
+      Vector3 distance = e.location - location;
+      return distance.length();
+    }
+
+    //! updates the data of an element
+    void update(Element arrayOfElements[]) {
+      if (this->movable == true) {calculateAcceleration(arrayOfElements);} //if element is movable, calculate acceleration
+    }
+
+    //! calculates the new acceleration of an element
+    void calculateAcceleration(Element arrayOfElements[]) {
+      acceleration = separation(arrayOfElements) + alignment(arrayOfElements) + cohesion(arrayOfElements);  //acceleration consisting of flocking-functions
+    }
+
+    //! separation-function (keep elements separated, avoid crashs)
+    Vector3 separation(Element arrayOfElements[]) {
+      using namespace Ogre;
+      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(int i=0; i<ANZELEMENTS; i++) {  //go through all elements
+        Element actual = arrayOfElements[i];  //get the actual element
+        distance = getDistance(actual);  //get distance between this and actual
+        if ((distance > 0) && (distance < SEPERATIONDISTANCE)) {  //do only if actual is inside detectionradius
+          inverseDistance = (0,0,0);
+          inverseDistance = location-actual.location;  //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 alignment(Element arrayOfElements[]) {
+      using namespace Ogre;
+      Vector3 steering = Vector3(0,0,0); //steeringvector
+      int numberOfNeighbour = 0;  //number of observed neighbours
+      float distance = 0;
+      //go through all elements
+      for(int i=0; i<ANZELEMENTS; i++) {  //just working with 3 elements at the moment
+        Element actual = arrayOfElements[i];  //get the actual element
+        float distance = getDistance(actual);  //get distance between this and actual
+        if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) {  //check if actual element is inside detectionradius
+          steering = steering + actual.speed;  //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 cohesion(Element arrayOfElements[]) {
+      using namespace Ogre;
+      Vector3 steering = Vector3(0,0,0); //steeringvector
+      int numberOfNeighbour = 0;  //number of observed neighbours
+      float distance = 0;
+      //go through all elements
+      for(int i=0; i<ANZELEMENTS; i++) {  //just working with 3 elements at the moment
+        Element actual = arrayOfElements[i];  //get the actual element
+        float distance = getDistance(actual);  //get distance between this and actual
+        if ((distance > 0) && (distance < COHESIONDISTANCE)) {  //check if actual element is inside detectionradius
+          steering = steering + actual.location;  //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->location;  //transform the vector for the ship
+      }
+      return steering;
+    }
+  };     //End of class Element
+}
+
+#endif /* _Flocking_H__*/
Index: /code/branches/network/src/asylum/orxonox/InputManager.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/InputManager.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/InputManager.cc	(revision 1545)
@@ -0,0 +1,390 @@
+#include "OrxonoxStableHeaders.h"
+
+#include "InputManager.h"
+
+InputManager *InputManager::mInputManager;
+
+InputManager::InputManager( void ) :
+    mMouse( 0 ), mKeyboard( 0 ), mInputSystem( 0 ) {}
+
+InputManager::~InputManager( void ) {
+  if( mInputSystem ) {
+    if( mMouse ) {
+      mInputSystem->destroyInputObject( mMouse );
+      mMouse = 0;
+    }
+
+    if( mKeyboard ) {
+      mInputSystem->destroyInputObject( mKeyboard );
+      mKeyboard = 0;
+    }
+
+    if( mJoysticks.size() > 0 ) {
+      itJoystick    = mJoysticks.begin();
+      itJoystickEnd = mJoysticks.end();
+      for(; itJoystick != itJoystickEnd; ++itJoystick ) {
+        mInputSystem->destroyInputObject( *itJoystick );
+      }
+
+      mJoysticks.clear();
+    }
+
+        // If you use OIS1.0RC1 or above, uncomment this line
+        // and comment the line below it
+    mInputSystem->destroyInputSystem( mInputSystem );
+        //mInputSystem->destroyInputSystem();
+    mInputSystem = 0;
+
+        // Clear Listeners
+    mKeyListeners.clear();
+    mMouseListeners.clear();
+    mJoystickListeners.clear();
+  }
+}
+
+void InputManager::initialise( Ogre::RenderWindow *renderWindow ) {
+  if( !mInputSystem ) {
+        // Setup basic variables
+    OIS::ParamList paramList;
+    size_t windowHnd = 0;
+    std::ostringstream windowHndStr;
+
+        // Get window handle
+    renderWindow->getCustomAttribute( "WINDOW", &windowHnd );
+
+        // Fill parameter list
+    windowHndStr << (unsigned int) windowHnd;
+    paramList.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );
+
+        // Create inputsystem
+    mInputSystem = OIS::InputManager::createInputSystem( paramList );
+
+        // If possible create a buffered keyboard
+        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0) {
+      if( mInputSystem->numKeyboards() > 0 ) {
+//     if (mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0) {
+      mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) );
+      mKeyboard->setEventCallback( this );
+    }
+
+        // If possible create a buffered mouse
+        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISMouse) > 0) {
+      if( mInputSystem->numMice() > 0 ) {
+//     if (mInputSystem->getNumberOfDevices(OIS::OISMouse) > 0) {
+      mMouse = static_cast<OIS::Mouse*>( mInputSystem->createInputObject( OIS::OISMouse, true ) );
+      mMouse->setEventCallback( this );
+
+            // Get window size
+      unsigned int width, height, depth;
+      int left, top;
+      renderWindow->getMetrics( width, height, depth, left, top );
+
+            // Set mouse region
+      this->setWindowExtents( width, height );
+    }
+
+        // If possible create all joysticks in buffered mode
+        // (note: if below line doesn't compile, try:  if (mInputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0) {
+    if( mInputSystem->numJoySticks() > 0 ) {
+//     if (mInputSystem->getNumberOfDevices(OIS::OISJoyStick) > 0) {
+       mJoysticks.resize( mInputSystem->numJoySticks() );
+//       mJoysticks.resize( mInputSystem->getNumberOfDevices(OIS::OISJoyStick) );
+
+      itJoystick    = mJoysticks.begin();
+      itJoystickEnd = mJoysticks.end();
+      for(; itJoystick != itJoystickEnd; ++itJoystick ) {
+        (*itJoystick) = static_cast<OIS::JoyStick*>( mInputSystem->createInputObject( OIS::OISJoyStick, true ) );
+        (*itJoystick)->setEventCallback( this );
+      }
+    }
+  }
+}
+
+void InputManager::capture( void ) {
+    // Need to capture / update each device every frame
+  if( mMouse ) {
+    mMouse->capture();
+  }
+
+  if( mKeyboard ) {
+    mKeyboard->capture();
+  }
+
+  if( mJoysticks.size() > 0 ) {
+    itJoystick    = mJoysticks.begin();
+    itJoystickEnd = mJoysticks.end();
+    for(; itJoystick != itJoystickEnd; ++itJoystick ) {
+      (*itJoystick)->capture();
+    }
+  }
+}
+
+void InputManager::addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName ) {
+  if( mKeyboard ) {
+        // Check for duplicate items
+    itKeyListener = mKeyListeners.find( instanceName );
+    if( itKeyListener == mKeyListeners.end() ) {
+      mKeyListeners[ instanceName ] = keyListener;
+    }
+    else {
+            // Duplicate Item
+    }
+  }
+}
+
+void InputManager::addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName ) {
+  if( mMouse ) {
+        // Check for duplicate items
+    itMouseListener = mMouseListeners.find( instanceName );
+    if( itMouseListener == mMouseListeners.end() ) {
+      mMouseListeners[ instanceName ] = mouseListener;
+    }
+    else {
+            // Duplicate Item
+    }
+  }
+}
+
+void InputManager::addJoystickListener( OIS::JoyStickListener *joystickListener, const std::string& instanceName ) {
+  if( mJoysticks.size() > 0 ) {
+        // Check for duplicate items
+    itJoystickListener = mJoystickListeners.find( instanceName );
+    if( itJoystickListener == mJoystickListeners.end() ) {
+      mJoystickListeners[ instanceName ] = joystickListener;
+    }
+    else {
+            // Duplicate Item
+    }
+  }
+}
+
+void InputManager::removeKeyListener( const std::string& instanceName ) {
+    // Check if item exists
+  itKeyListener = mKeyListeners.find( instanceName );
+  if( itKeyListener != mKeyListeners.end() ) {
+    mKeyListeners.erase( itKeyListener );
+  }
+  else {
+        // Doesn't Exist
+  }
+}
+
+void InputManager::removeMouseListener( const std::string& instanceName ) {
+    // Check if item exists
+  itMouseListener = mMouseListeners.find( instanceName );
+  if( itMouseListener != mMouseListeners.end() ) {
+    mMouseListeners.erase( itMouseListener );
+  }
+  else {
+        // Doesn't Exist
+  }
+}
+
+void InputManager::removeJoystickListener( const std::string& instanceName ) {
+    // Check if item exists
+  itJoystickListener = mJoystickListeners.find( instanceName );
+  if( itJoystickListener != mJoystickListeners.end() ) {
+    mJoystickListeners.erase( itJoystickListener );
+  }
+  else {
+        // Doesn't Exist
+  }
+}
+
+void InputManager::removeKeyListener( OIS::KeyListener *keyListener ) {
+  itKeyListener    = mKeyListeners.begin();
+  itKeyListenerEnd = mKeyListeners.end();
+  for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) {
+    if( itKeyListener->second == keyListener ) {
+      mKeyListeners.erase( itKeyListener );
+      break;
+    }
+  }
+}
+
+void InputManager::removeMouseListener( OIS::MouseListener *mouseListener ) {
+  itMouseListener    = mMouseListeners.begin();
+  itMouseListenerEnd = mMouseListeners.end();
+  for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) {
+    if( itMouseListener->second == mouseListener ) {
+      mMouseListeners.erase( itMouseListener );
+      break;
+    }
+  }
+}
+
+void InputManager::removeJoystickListener( OIS::JoyStickListener *joystickListener ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if( itJoystickListener->second == joystickListener ) {
+      mJoystickListeners.erase( itJoystickListener );
+      break;
+    }
+  }
+}
+
+void InputManager::removeAllListeners( void ) {
+  mKeyListeners.clear();
+  mMouseListeners.clear();
+  mJoystickListeners.clear();
+}
+
+void InputManager::removeAllKeyListeners( void ) {
+  mKeyListeners.clear();
+}
+
+void InputManager::removeAllMouseListeners( void ) {
+  mMouseListeners.clear();
+}
+
+void InputManager::removeAllJoystickListeners( void ) {
+  mJoystickListeners.clear();
+}
+
+void InputManager::setWindowExtents( int width, int height ) {
+    // Set mouse region (if window resizes, we should alter this to reflect as well)
+  const OIS::MouseState &mouseState = mMouse->getMouseState();
+  mouseState.width  = width;
+  mouseState.height = height;
+}
+
+OIS::Mouse* InputManager::getMouse( void ) {
+  return mMouse;
+}
+
+OIS::Keyboard* InputManager::getKeyboard( void ) {
+  return mKeyboard;
+}
+
+OIS::JoyStick* InputManager::getJoystick( unsigned int index ) {
+    // Make sure it's a valid index
+  if( index < mJoysticks.size() ) {
+    return mJoysticks[ index ];
+  }
+
+  return 0;
+}
+
+int InputManager::getNumOfJoysticks( void ) {
+    // Cast to keep compiler happy ^^
+  return (int) mJoysticks.size();
+}
+
+bool InputManager::keyPressed( const OIS::KeyEvent &e ) {
+  itKeyListener    = mKeyListeners.begin();
+  itKeyListenerEnd = mKeyListeners.end();
+  for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) {
+    if(!itKeyListener->second->keyPressed( e ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::keyReleased( const OIS::KeyEvent &e ) {
+  itKeyListener    = mKeyListeners.begin();
+  itKeyListenerEnd = mKeyListeners.end();
+  for(; itKeyListener != itKeyListenerEnd; ++itKeyListener ) {
+    if(!itKeyListener->second->keyReleased( e ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::mouseMoved( const OIS::MouseEvent &e ) {
+  itMouseListener    = mMouseListeners.begin();
+  itMouseListenerEnd = mMouseListeners.end();
+  for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) {
+    if(!itMouseListener->second->mouseMoved( e ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id ) {
+  itMouseListener    = mMouseListeners.begin();
+  itMouseListenerEnd = mMouseListeners.end();
+  for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) {
+    if(!itMouseListener->second->mousePressed( e, id ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id ) {
+  itMouseListener    = mMouseListeners.begin();
+  itMouseListenerEnd = mMouseListeners.end();
+  for(; itMouseListener != itMouseListenerEnd; ++itMouseListener ) {
+    if(!itMouseListener->second->mouseReleased( e, id ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::povMoved( const OIS::JoyStickEvent &e, int pov ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if(!itJoystickListener->second->povMoved( e, pov ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::axisMoved( const OIS::JoyStickEvent &e, int axis ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if(!itJoystickListener->second->axisMoved( e, axis ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::sliderMoved( const OIS::JoyStickEvent &e, int sliderID ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if(!itJoystickListener->second->sliderMoved( e, sliderID ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::buttonPressed( const OIS::JoyStickEvent &e, int button ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if(!itJoystickListener->second->buttonPressed( e, button ))
+      break;
+  }
+
+  return true;
+}
+
+bool InputManager::buttonReleased( const OIS::JoyStickEvent &e, int button ) {
+  itJoystickListener    = mJoystickListeners.begin();
+  itJoystickListenerEnd = mJoystickListeners.end();
+  for(; itJoystickListener != itJoystickListenerEnd; ++itJoystickListener ) {
+    if(!itJoystickListener->second->buttonReleased( e, button ))
+      break;
+  }
+
+  return true;
+}
+
+InputManager* InputManager::getSingletonPtr( void ) {
+  if( !mInputManager ) {
+    mInputManager = new InputManager();
+  }
+
+  return mInputManager;
+}
Index: /code/branches/network/src/asylum/orxonox/InputManager.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/InputManager.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/InputManager.h	(revision 1545)
@@ -0,0 +1,93 @@
+#ifndef _InputManager_H__
+#define _InputManager_H__
+
+#ifdef WIN32
+#include <OIS/OISMouse.h>
+#include <OIS/OISKeyboard.h>
+#include <OIS/OISJoyStick.h>
+#include <OIS/OISInputManager.h>
+#else
+#include <OISMouse.h>
+#include <OISKeyboard.h>
+#include <OISJoyStick.h>
+#include <OISInputManager.h>
+#endif
+
+#include <OgreRenderWindow.h>
+
+#include "OrxonoxPrereqs.h"
+
+class _OrxonoxExport InputManager : public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener {
+  public:
+    virtual ~InputManager( void );
+
+    void initialise( Ogre::RenderWindow *renderWindow );
+    void capture( void );
+
+    void addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName );
+    void addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName );
+    void addJoystickListener( OIS::JoyStickListener *joystickListener, const std::string& instanceName );
+
+    void removeKeyListener( const std::string& instanceName );
+    void removeMouseListener( const std::string& instanceName );
+    void removeJoystickListener( const std::string& instanceName );
+
+    void removeKeyListener( OIS::KeyListener *keyListener );
+    void removeMouseListener( OIS::MouseListener *mouseListener );
+    void removeJoystickListener( OIS::JoyStickListener *joystickListener );
+
+    void removeAllListeners( void );
+    void removeAllKeyListeners( void );
+    void removeAllMouseListeners( void );
+    void removeAllJoystickListeners( void );
+
+    void setWindowExtents( int width, int height );
+
+    OIS::Mouse*    getMouse( void );
+    OIS::Keyboard* getKeyboard( void );
+    OIS::JoyStick* getJoystick( unsigned int index );
+
+    int getNumOfJoysticks( void );
+
+    static InputManager* getSingletonPtr( void );
+  private:
+    InputManager( void );
+    InputManager( const InputManager& ) { }
+    InputManager & operator = ( const InputManager& );
+
+    bool keyPressed( const OIS::KeyEvent &e );
+    bool keyReleased( const OIS::KeyEvent &e );
+
+    bool mouseMoved( const OIS::MouseEvent &e );
+    bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
+    bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );
+
+    bool povMoved( const OIS::JoyStickEvent &e, int pov );
+    bool axisMoved( const OIS::JoyStickEvent &e, int axis );
+    bool sliderMoved( const OIS::JoyStickEvent &e, int sliderID );
+    bool buttonPressed( const OIS::JoyStickEvent &e, int button );
+    bool buttonReleased( const OIS::JoyStickEvent &e, int button );
+
+    OIS::Mouse        *mMouse;
+    OIS::Keyboard     *mKeyboard;
+    OIS::InputManager *mInputSystem;
+
+    std::vector<OIS::JoyStick*> mJoysticks;
+    std::vector<OIS::JoyStick*>::iterator itJoystick;
+    std::vector<OIS::JoyStick*>::iterator itJoystickEnd;
+
+    std::map<std::string, OIS::KeyListener*> mKeyListeners;
+    std::map<std::string, OIS::MouseListener*> mMouseListeners;
+    std::map<std::string, OIS::JoyStickListener*> mJoystickListeners;
+
+    std::map<std::string, OIS::KeyListener*>::iterator itKeyListener;
+    std::map<std::string, OIS::MouseListener*>::iterator itMouseListener;
+    std::map<std::string, OIS::JoyStickListener*>::iterator itJoystickListener;
+
+    std::map<std::string, OIS::KeyListener*>::iterator itKeyListenerEnd;
+    std::map<std::string, OIS::MouseListener*>::iterator itMouseListenerEnd;
+    std::map<std::string, OIS::JoyStickListener*>::iterator itJoystickListenerEnd;
+
+    static InputManager *mInputManager;
+};
+#endif /* _InputManager_H__ */
Index: /code/branches/network/src/asylum/orxonox/SpaceshipSteering.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/SpaceshipSteering.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/SpaceshipSteering.cc	(revision 1545)
@@ -0,0 +1,233 @@
+/*
+*   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:
+*      ...
+*
+*/
+
+#include "OrxonoxStableHeaders.h"
+
+#include <OgreNode.h>
+#include <OgreSceneNode.h>
+
+#include "core/Debug.h"
+#include "util/Math.h"
+#include "SpaceshipSteering.h"
+
+namespace orxonox
+{
+
+  SpaceshipSteering::SpaceshipSteering(float maxSpeedForward, float
+    maxSpeedRotateUpDown, float maxSpeedRotateRightLeft, float
+    maxSpeedLoopRightLeft)
+  {
+
+      COUT(3) << "Info: Steering was loaded" << std::endl;
+      moveForward_ = 0;
+      rotateUp_ = 0;
+      rotateDown_ = 0;
+      rotateRight_ = 0;
+      rotateLeft_ = 0;
+      loopRight_ = 0;
+      loopLeft_ = 0;
+      brakeForward_ = 0;
+      brakeRotate_ = 0;
+      brakeLoop_ = 0;
+      speedForward_ = 0;
+      speedRotateUpDown_ = 0;
+      speedRotateRightLeft_ = 0;
+      speedLoopRightLeft_ = 0;
+      maxSpeedForward_ = maxSpeedForward;
+      maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
+      maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
+      maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
+      accelerationForward_ = 0;
+      accelerationRotateUpDown_ = 0;
+      accelerationRotateRightLeft_ = 0;
+      accelerationLoopRightLeft_ = 0;
+  }
+
+  void SpaceshipSteering::tick(float time)
+  {
+
+    if(moveForward_ > 0) {
+      accelerationForward_ = moveForward_;
+      if(speedForward_ < maxSpeedForward_)
+        speedForward_ += accelerationForward_*time;
+      if(speedForward_ > maxSpeedForward_)
+        speedForward_ = maxSpeedForward_;
+    }
+    if(moveForward_ <= 0) {
+      accelerationForward_ = brakeForward_;
+      if(speedForward_ > 0)
+        speedForward_ -= accelerationForward_*time;
+      if(speedForward_ < 0)
+        speedForward_ = 0;
+    }
+
+    if(rotateUp_ > 0) {
+      accelerationRotateUpDown_ = rotateUp_;
+      if(speedRotateUpDown_ < maxSpeedRotateUpDown_)
+        speedRotateUpDown_ += accelerationRotateUpDown_*time;
+      if(speedRotateUpDown_ > maxSpeedRotateUpDown_)
+        speedRotateUpDown_ = maxSpeedRotateUpDown_;
+    }
+    if(rotateDown_ > 0) {
+      accelerationRotateUpDown_ = rotateDown_;
+      if(speedRotateUpDown_ > -maxSpeedRotateUpDown_)
+        speedRotateUpDown_ -= accelerationRotateUpDown_*time;
+      if(speedRotateUpDown_ < -maxSpeedRotateUpDown_)
+        speedRotateUpDown_ = -maxSpeedRotateUpDown_;
+    }
+    if(rotateUp_ == 0 && rotateDown_ == 0) {
+      accelerationRotateUpDown_ = brakeRotate_;
+      if(speedRotateUpDown_ > 0)
+        speedRotateUpDown_ -= accelerationRotateUpDown_*time;
+      if(speedRotateUpDown_ < 0)
+        speedRotateUpDown_ += accelerationRotateUpDown_*time;
+      if(fabsf(speedRotateUpDown_)<accelerationRotateUpDown_*time)
+        speedRotateUpDown_ = 0;
+    }
+
+    if(rotateRight_ > 0) {
+      accelerationRotateRightLeft_ = rotateRight_;
+      if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_)
+        speedRotateRightLeft_ -= accelerationRotateRightLeft_*time;
+      if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_)
+        speedRotateRightLeft_ = -maxSpeedRotateRightLeft_;
+    }
+    if(rotateLeft_ > 0) {
+      accelerationRotateRightLeft_ = rotateLeft_;
+      if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_)
+        speedRotateRightLeft_ += accelerationRotateRightLeft_*time;
+      if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_)
+        speedRotateRightLeft_ = maxSpeedRotateRightLeft_;
+    }
+    if(rotateRight_ == 0 && rotateLeft_ == 0) {
+      accelerationRotateRightLeft_ = brakeRotate_;
+      if(speedRotateRightLeft_ > 0)
+        speedRotateRightLeft_ -= accelerationRotateRightLeft_*time;
+      if(speedRotateRightLeft_ < 0)
+        speedRotateRightLeft_ += accelerationRotateRightLeft_*time;
+      if(fabsf(speedRotateRightLeft_)<accelerationRotateRightLeft_*time)
+        speedRotateRightLeft_ = 0;
+    }
+
+    if(loopRight_ > 0) {
+      accelerationLoopRightLeft_ = loopRight_;
+      if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_)
+        speedLoopRightLeft_ += accelerationLoopRightLeft_*time;
+      if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_)
+        speedLoopRightLeft_ = maxSpeedLoopRightLeft_;
+    }
+    if(loopLeft_ > 0) {
+      accelerationLoopRightLeft_ = loopLeft_;
+      if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_)
+        speedLoopRightLeft_ -= accelerationLoopRightLeft_*time;
+      if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_)
+        speedLoopRightLeft_ = -maxSpeedLoopRightLeft_;
+    }
+    if(loopLeft_ == 0 && loopRight_ == 0) {
+      accelerationLoopRightLeft_ = brakeLoop_;
+      if(speedLoopRightLeft_ > 0)
+        speedLoopRightLeft_ -= accelerationLoopRightLeft_*time;
+      if(speedLoopRightLeft_ < 0)
+        speedLoopRightLeft_ += accelerationLoopRightLeft_*time;
+      if(fabsf(speedLoopRightLeft_)<accelerationLoopRightLeft_*time)
+        speedLoopRightLeft_ = 0;
+    }
+
+    Vector3 transVector = Vector3::ZERO;
+    transVector.z = 1;
+    steeringNode_->translate(transVector*speedForward_*time,
+      Ogre::SceneNode::TS_LOCAL);
+    steeringNode_->pitch(Degree(speedRotateUpDown_*time),
+      Ogre::SceneNode::TS_LOCAL);
+    steeringNode_->yaw(Degree(speedRotateRightLeft_*time),
+      Ogre::SceneNode::TS_LOCAL);
+    steeringNode_->roll(Degree(speedLoopRightLeft_*time),
+      Ogre::SceneNode::TS_LOCAL);
+
+  }
+
+  void SpaceshipSteering::moveForward(float moveForward) {
+    moveForward_ = moveForward;
+  }
+
+  void SpaceshipSteering::rotateUp(float rotateUp) {
+    rotateUp_ = rotateUp;
+  }
+
+  void SpaceshipSteering::rotateDown(float rotateDown) {
+    rotateDown_ = rotateDown;
+  }
+
+  void SpaceshipSteering::rotateLeft(float rotateLeft) {
+    rotateLeft_ = rotateLeft;
+  }
+
+  void SpaceshipSteering::rotateRight(float rotateRight) {
+    rotateRight_ = rotateRight;
+  }
+
+  void SpaceshipSteering::loopLeft(float loopLeft) {
+    loopLeft_ = loopLeft;
+  }
+
+  void SpaceshipSteering::loopRight(float loopRight) {
+    loopRight_ = loopRight;
+  }
+
+  void SpaceshipSteering::brakeForward(float brakeForward) {
+    brakeForward_ = brakeForward;
+  }
+
+  void SpaceshipSteering::brakeRotate(float brakeRotate) {
+    brakeRotate_ = brakeRotate;
+  }
+
+  void SpaceshipSteering::brakeLoop(float brakeLoop) {
+    brakeLoop_ = brakeLoop;
+  }
+
+  void SpaceshipSteering::maxSpeedForward(float maxSpeedForward) {
+    maxSpeedForward_ = maxSpeedForward;
+  }
+
+  void SpaceshipSteering::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) {
+    maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
+  }
+
+  void SpaceshipSteering::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) {
+    maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
+  }
+
+  void SpaceshipSteering::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) {
+    maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
+  }
+
+  void SpaceshipSteering::addNode(Ogre::SceneNode *steeringNode) {
+    steeringNode_ = steeringNode;
+  }
+
+}
Index: /code/branches/network/src/asylum/orxonox/SpaceshipSteering.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/SpaceshipSteering.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/SpaceshipSteering.h	(revision 1545)
@@ -0,0 +1,66 @@
+#ifndef _SpaceShipSteering_H__
+#define _SpaceShipSteering_H__
+
+#include <OgrePrerequisites.h>
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport SpaceshipSteering
+  {
+  public:
+    SpaceshipSteering(float maxSpeedForward, float maxSpeedRotateUpDown,
+      float maxSpeedRotateRightLeft, float maxSpeedLoopRightLeft);
+    void tick(float time);
+    void moveForward(float moveForward);
+    void rotateUp(float rotateUp);
+    void rotateDown(float rotateDown);
+    void rotateRight(float rotateRight);
+    void rotateLeft(float rotateLeft);
+    void loopRight(float loopRight);
+    void loopLeft(float loopLeft);
+    void brakeForward(float brakeForward);
+    void brakeRotate(float brakeRotate);
+    void brakeLoop(float brakeLoop);
+    void maxSpeedForward(float maxSpeedForward);
+    void maxSpeedRotateUpDown(float maxSpeedRotateUpDown);
+    void maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft);
+    void maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft);
+    void addNode(Ogre::SceneNode *steeringNode);
+
+  protected:
+    Ogre::SceneNode *steeringNode_;
+
+  private:
+    float moveForward_;
+    float rotateUp_;
+    float rotateDown_;
+    float rotateRight_;
+    float rotateLeft_;
+    float loopRight_;
+    float loopLeft_;
+    float brakeForward_;
+    float brakeRotate_;
+    float brakeLoop_;
+
+    float speedForward_;
+    float speedRotateUpDown_;
+    float speedRotateRightLeft_;
+    float speedLoopRightLeft_;
+
+    float maxSpeedForward_;
+    float maxSpeedRotateUpDown_;
+    float maxSpeedRotateRightLeft_;
+    float maxSpeedLoopRightLeft_;
+
+    float accelerationForward_;
+    float accelerationRotateUpDown_;
+    float accelerationRotateRightLeft_;
+    float accelerationLoopRightLeft_;
+
+  };
+}
+
+
+#endif /* _SpaceShipSteering_H__ */
Index: /code/branches/network/src/asylum/orxonox/objects/Fighter.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/Fighter.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/Fighter.cc	(revision 1545)
@@ -0,0 +1,513 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <string>
+
+#include <OgreCamera.h>
+#include <OgreRenderWindow.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+
+#include "util/tinyxml/tinyxml.h"
+#include "util/String2Number.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "GraphicsEngine.h"
+#include "core/InputManager.h"
+#include "particle/ParticleInterface.h"
+#include "weapon/AmmunitionDump.h"
+#include "weapon/BarrelGun.h"
+
+#include "Fighter.h"
+
+namespace orxonox
+{
+    CreateFactory(Fighter);
+
+    Fighter::Fighter()
+    {
+        RegisterObject(Fighter);
+
+        this->setConfigValues();
+
+        this->setMouseEventCallback_ = false;
+
+        this->w = NULL;
+        this->tt = NULL;
+        this->ammoDump_ = NULL;
+        this->mainWeapon_ = NULL;
+        this->rightButtonPressed_ = false;
+        this->leftButtonPressed_ = false;
+
+        this->moveForward_ = 0;
+        this->rotateUp_ = 0;
+        this->rotateDown_ = 0;
+        this->rotateRight_ = 0;
+        this->rotateLeft_ = 0;
+        this->loopRight_ = 0;
+        this->loopLeft_ = 0;
+        this->brakeForward_ = 0;
+        this->brakeRotate_ = 0;
+        this->brakeLoop_ = 0;
+        this->speedForward_ = 0;
+        this->speedRotateUpDown_ = 0;
+        this->speedRotateRightLeft_ = 0;
+        this->speedLoopRightLeft_ = 0;
+        this->maxSpeedForward_ = 0;
+        this->maxSpeedRotateUpDown_ = 0;
+        this->maxSpeedRotateRightLeft_ = 0;
+        this->maxSpeedLoopRightLeft_ = 0;
+        this->accelerationForward_ = 0;
+        this->accelerationRotateUpDown_ = 0;
+        this->accelerationRotateRightLeft_ = 0;
+        this->accelerationLoopRightLeft_ = 0;
+
+        this->speed = 250;
+        this->loop = 100;
+        this->rotate = 10;
+        this->mouseX = 0;
+        this->mouseY = 0;
+        this->maxMouseX = 0;
+        this->minMouseX = 0;
+        this->moved = false;
+
+        this->brakeRotate(rotate*10);
+        this->brakeLoop(loop);
+
+        COUT(3) << "Info: Fighter was loaded" << std::endl;
+    }
+
+    Fighter::~Fighter()
+    {
+        if (w)
+            delete w;
+        if (tt)
+            delete tt;
+    }
+
+    void Fighter::setConfigValues()
+    {
+        SetConfigValue(bInvertMouse_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
+    }
+
+    void Fighter::setMaxSpeedValues(float maxSpeedForward, float maxSpeedRotateUpDown, float maxSpeedRotateRightLeft, float maxSpeedLoopRightLeft)
+    {
+        this->maxSpeedForward_ = maxSpeedForward;
+        this->maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
+        this->maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
+        this->maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
+    }
+
+    void Fighter::loadParams(TiXmlElement* xmlElem)
+    {
+        Model::loadParams(xmlElem);
+
+#if 0
+        w = new particle::ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"schuss" + this->getName(),"Orxonox/schuss");
+        w->getParticleSystem()->setParameter("local_space","true");
+        w->newEmitter();
+/*
+        w->setDirection(Vector3(0,0,1));
+        w->setPositionOfEmitter(0, Vector3(10,10,0));
+        w->setPositionOfEmitter(1, Vector3(-10,10,0));
+*/
+        w->setDirection(Vector3(1,0,0));
+        w->setPositionOfEmitter(0, Vector3(0,10,10));
+        w->setPositionOfEmitter(1, Vector3(0,-10,10));
+
+        emitterRate_ = w->getRate();
+
+        Ogre::SceneNode* node1 = this->getNode()->createChildSceneNode(this->getName() + "particle1");
+        node1->setInheritScale(false);
+        w->addToSceneNode(node1);
+#endif
+
+        tt = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
+        tt->getParticleSystem()->setParameter("local_space","true");
+        tt->newEmitter();
+/*
+        tt->setDirection(Vector3(0,0,1));
+        tt->setPositionOfEmitter(0, Vector3(20,-1,-15));
+        tt->setPositionOfEmitter(1, Vector3(-20,-1,-15));
+*/
+        tt->setDirection(Vector3(-1,0,0));
+        tt->setPositionOfEmitter(0, Vector3(-15,20,-1));
+        tt->setPositionOfEmitter(1, Vector3(-15,-20,-1));
+        tt->setVelocity(50);
+
+        Ogre::SceneNode* node2 = this->getNode()->createChildSceneNode(this->getName() + "particle2");
+        node2->setInheritScale(false);
+        tt->addToSceneNode(node2);
+
+        // add weapon
+
+        ammoDump_ = new AmmunitionDump();
+        ammoDump_->setDumpSize("Barrel", 1000);
+        ammoDump_->store("Barrel", 420);
+
+        mainWeapon_ = new BarrelGun();
+        mainWeapon_->setAmmoDump(ammoDump_);
+        GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(mainWeapon_->getNode());
+        getNode()->addChild(mainWeapon_->getNode());
+
+        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
+        {
+            std::string forwardStr = xmlElem->Attribute("forward");
+            std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
+            std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
+            std::string looprightleftStr = xmlElem->Attribute("looprightleft");
+
+            String2Number<float>(this->maxSpeedForward_, forwardStr);
+            String2Number<float>(this->maxSpeedRotateUpDown_, rotateupdownStr);
+            String2Number<float>(this->maxSpeedRotateRightLeft_, rotaterightleftStr);
+            String2Number<float>(this->maxSpeedLoopRightLeft_, looprightleftStr);
+
+            COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
+    	}
+
+    	if (xmlElem->Attribute("camera"))
+    	{
+            Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");
+            Ogre::SceneNode *node = this->getNode()->createChildSceneNode("CamNode");
+/*
+//            node->setInheritOrientation(false);
+            cam->setPosition(Vector3(0,50,-150));
+            cam->lookAt(Vector3(0,20,0));
+            cam->roll(Degree(0));
+*/
+
+            cam->setPosition(Vector3(-150,0,50));
+//            cam->setPosition(Vector3(0,-350,0));
+            cam->lookAt(Vector3(0,0,20));
+            cam->roll(Degree(-90));
+
+            node->attachObject(cam);
+            GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
+    	}
+    }
+
+    bool Fighter::mouseMoved(const OIS::MouseEvent &e)
+    {
+        this->mouseX += e.state.X.rel;
+        //if (this->bInvertMouse_)
+            //this->mouseY += e.state.Y.rel;
+        //else
+            this->mouseY -= e.state.Y.rel;
+
+//        if(mouseX>maxMouseX) maxMouseX = mouseX;
+//        if(mouseX<minMouseX) minMouseX = mouseX;
+//        cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
+
+        this->moved = true;
+
+        return true;
+    }
+
+    bool Fighter::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id )
+    {
+      if (id == OIS::MB_Left)
+      {
+        this->leftButtonPressed_ = true;
+      }
+      else if (id == OIS::MB_Right)
+        this->rightButtonPressed_ = true;
+      return true;
+    }
+
+    bool Fighter::mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id )
+    {
+      if (id == OIS::MB_Left)
+      {
+        this->leftButtonPressed_ = false;
+      }
+      else if (id == OIS::MB_Right)
+        this->rightButtonPressed_ = false;
+      return true;
+    }
+
+    void Fighter::tick(float dt)
+    {
+        if (!this->setMouseEventCallback_)
+        {
+            if (InputManager::getSingleton()->getMouse())
+            {
+                InputManager::getSingleton()->getMouse()->setEventCallback(this);
+                this->setMouseEventCallback_ = true;
+            }
+        }
+
+        WorldEntity::tick(dt);
+
+        OIS::Keyboard* mKeyboard = InputManager::getSingleton()->getKeyboard();
+        OIS::Mouse* mMouse = InputManager::getSingleton()->getMouse();
+
+        //mKeyboard->capture();
+        //mMouse->capture();
+
+        if (leftButtonPressed_)
+            mainWeapon_->primaryFireRequest();
+        if (rightButtonPressed_)
+            mainWeapon_->secondaryFireRequest();
+
+        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
+            this->moveForward(speed);
+        else
+            this->moveForward(0);
+
+        if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
+            this->brakeForward(speed);
+        else
+            this->brakeForward(speed/10);
+
+        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
+            this->loopRight(loop);
+        else
+            this->loopRight(0);
+
+        if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
+            this->loopLeft(loop);
+        else
+            this->loopLeft(0);
+
+        if (mKeyboard->isKeyDown(OIS::KC_G))
+            this->mainWeapon_->addAction(BaseWeapon::RELOAD);
+        else
+            this->loopLeft(0);
+
+        if(moved)
+        {
+            if (mouseY<=0)
+                this->rotateUp(-mouseY*rotate);
+            if (mouseY>0)
+                this->rotateDown(mouseY*rotate);
+            if (mouseX>0)
+                this->rotateRight(mouseX*rotate);
+            if (mouseX<=0)
+                this->rotateLeft(-mouseX*rotate);
+
+            mouseY = 0;
+            mouseX = 0;
+            moved = false;
+        }
+        else
+        {
+            this->rotateUp(0);
+            this->rotateDown(0);
+            this->rotateRight(0);
+            this->rotateLeft(0);
+        }
+
+        if(moveForward_ > 0)
+        {
+            accelerationForward_ = moveForward_;
+            if(speedForward_ < maxSpeedForward_)
+                speedForward_ += accelerationForward_*dt;
+            if(speedForward_ > maxSpeedForward_)
+                speedForward_ = maxSpeedForward_;
+        }
+
+        if(moveForward_ <= 0)
+        {
+            accelerationForward_ = -brakeForward_;
+            if(speedForward_ > 0)
+                speedForward_ += accelerationForward_*dt;
+            if(speedForward_ < 0)
+                speedForward_ = 0;
+        }
+
+        if(rotateUp_ > 0)
+        {
+            accelerationRotateUpDown_ = rotateUp_;
+            if(speedRotateUpDown_ < maxSpeedRotateUpDown_)
+                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
+            if(speedRotateUpDown_ > maxSpeedRotateUpDown_)
+            speedRotateUpDown_ = maxSpeedRotateUpDown_;
+        }
+
+        if(rotateDown_ > 0)
+        {
+            accelerationRotateUpDown_ = rotateDown_;
+            if(speedRotateUpDown_ > -maxSpeedRotateUpDown_)
+                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
+            if(speedRotateUpDown_ < -maxSpeedRotateUpDown_)
+                speedRotateUpDown_ = -maxSpeedRotateUpDown_;
+        }
+
+        if(rotateUp_ == 0 && rotateDown_ == 0)
+        {
+            accelerationRotateUpDown_ = brakeRotate_;
+            if(speedRotateUpDown_ > 0)
+                speedRotateUpDown_ -= accelerationRotateUpDown_*dt;
+            if(speedRotateUpDown_ < 0)
+                speedRotateUpDown_ += accelerationRotateUpDown_*dt;
+            if(fabs(speedRotateUpDown_) < accelerationRotateUpDown_*dt)
+                speedRotateUpDown_ = 0;
+        }
+
+        if(rotateRight_ > 0)
+        {
+            accelerationRotateRightLeft_ = rotateRight_;
+            if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_)
+                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
+            if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_)
+                speedRotateRightLeft_ = -maxSpeedRotateRightLeft_;
+        }
+
+        if(rotateLeft_ > 0)
+        {
+            accelerationRotateRightLeft_ = rotateLeft_;
+            if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_)
+                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
+            if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_)
+                speedRotateRightLeft_ = maxSpeedRotateRightLeft_;
+        }
+
+        if(rotateRight_ == 0 && rotateLeft_ == 0)
+        {
+            accelerationRotateRightLeft_ = brakeRotate_;
+            if(speedRotateRightLeft_ > 0)
+                speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt;
+            if(speedRotateRightLeft_ < 0)
+                speedRotateRightLeft_ += accelerationRotateRightLeft_*dt;
+            if(fabs(speedRotateRightLeft_) < accelerationRotateRightLeft_*dt)
+                speedRotateRightLeft_ = 0;
+        }
+
+        if(loopRight_ > 0)
+        {
+            accelerationLoopRightLeft_ = loopRight_;
+            if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_)
+                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
+            if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_)
+                speedLoopRightLeft_ = maxSpeedLoopRightLeft_;
+        }
+
+        if(loopLeft_ > 0)
+        {
+            accelerationLoopRightLeft_ = loopLeft_;
+            if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_)
+                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
+            if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_)
+                speedLoopRightLeft_ = -maxSpeedLoopRightLeft_;
+        }
+
+        if(loopLeft_ == 0 && loopRight_ == 0)
+        {
+            accelerationLoopRightLeft_ = brakeLoop_;
+            if(speedLoopRightLeft_ > 0)
+                speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt;
+            if(speedLoopRightLeft_ < 0)
+                speedLoopRightLeft_ += accelerationLoopRightLeft_*dt;
+            if(fabs(speedLoopRightLeft_) < accelerationLoopRightLeft_*dt)
+                speedLoopRightLeft_ = 0;
+        }
+
+        Vector3 transVector = Vector3::ZERO;
+/*
+        transVector.z = 1;
+        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
+        this->pitch(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
+        this->yaw(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
+        this->roll(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
+*/
+
+        transVector.x = 1;
+        this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL);
+        this->yaw(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL);
+        this->roll(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL);
+        this->pitch(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL);
+
+        if (accelerationForward_ > 25.0)
+        {
+          this->tt->setRate(emitterRate_);
+        }
+        else
+        {
+          this->tt->setRate(0);
+        }
+
+    }
+
+    void Fighter::moveForward(float moveForward) {
+        moveForward_ = moveForward;
+    }
+
+    void Fighter::rotateUp(float rotateUp) {
+        rotateUp_ = rotateUp;
+    }
+
+    void Fighter::rotateDown(float rotateDown) {
+        rotateDown_ = rotateDown;
+    }
+
+    void Fighter::rotateLeft(float rotateLeft) {
+        rotateLeft_ = rotateLeft;
+    }
+
+    void Fighter::rotateRight(float rotateRight) {
+        rotateRight_ = rotateRight;
+    }
+
+    void Fighter::loopLeft(float loopLeft) {
+        loopLeft_ = loopLeft;
+    }
+
+    void Fighter::loopRight(float loopRight) {
+        loopRight_ = loopRight;
+    }
+
+    void Fighter::brakeForward(float brakeForward) {
+        brakeForward_ = brakeForward;
+    }
+
+    void Fighter::brakeRotate(float brakeRotate) {
+        brakeRotate_ = brakeRotate;
+    }
+
+    void Fighter::brakeLoop(float brakeLoop) {
+        brakeLoop_ = brakeLoop;
+    }
+
+    void Fighter::maxSpeedForward(float maxSpeedForward) {
+        maxSpeedForward_ = maxSpeedForward;
+    }
+
+    void Fighter::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) {
+        maxSpeedRotateUpDown_ = maxSpeedRotateUpDown;
+    }
+
+    void Fighter::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) {
+        maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft;
+    }
+
+    void Fighter::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) {
+        maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft;
+    }
+}
Index: /code/branches/network/src/asylum/orxonox/objects/Fighter.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/Fighter.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/Fighter.h	(revision 1545)
@@ -0,0 +1,92 @@
+#ifndef _Fighter_H__
+#define _Fighter_H__
+
+#include <OIS/OIS.h>
+
+#include "../OrxonoxPrereqs.h"
+
+#include "Model.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Fighter : public Model, public OIS::MouseListener
+    {
+        public:
+            Fighter();
+            ~Fighter();
+            void setConfigValues();
+            virtual void loadParams(TiXmlElement* xmlElem);
+            void setMaxSpeedValues(float maxSpeedForward, float maxSpeedRotateUpDown, float maxSpeedRotateRightLeft, float maxSpeedLoopRightLeft);
+            virtual void tick(float dt);
+            void moveForward(float moveForward);
+            void rotateUp(float rotateUp);
+            void rotateDown(float rotateDown);
+            void rotateRight(float rotateRight);
+            void rotateLeft(float rotateLeft);
+            void loopRight(float loopRight);
+            void loopLeft(float loopLeft);
+            void brakeForward(float brakeForward);
+            void brakeRotate(float brakeRotate);
+            void brakeLoop(float brakeLoop);
+            void maxSpeedForward(float maxSpeedForward);
+            void maxSpeedRotateUpDown(float maxSpeedRotateUpDown);
+            void maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft);
+            void maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft);
+            bool mouseMoved(const OIS::MouseEvent &e);
+            bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);// { return true; }
+            bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);// { return true; }
+
+
+        private:
+            bool bInvertMouse_;
+            bool setMouseEventCallback_;
+
+            ParticleInterface *w;
+            ParticleInterface *tt;
+
+            AmmunitionDump* ammoDump_;
+            BarrelGun* mainWeapon_;
+
+            bool leftButtonPressed_;
+            bool rightButtonPressed_;
+
+            float moveForward_;
+            float rotateUp_;
+            float rotateDown_;
+            float rotateRight_;
+            float rotateLeft_;
+            float loopRight_;
+            float loopLeft_;
+            float brakeForward_;
+            float brakeRotate_;
+            float brakeLoop_;
+
+            float speedForward_;
+            float speedRotateUpDown_;
+            float speedRotateRightLeft_;
+            float speedLoopRightLeft_;
+
+            float maxSpeedForward_;
+            float maxSpeedRotateUpDown_;
+            float maxSpeedRotateRightLeft_;
+            float maxSpeedLoopRightLeft_;
+
+            float accelerationForward_;
+            float accelerationRotateUpDown_;
+            float accelerationRotateRightLeft_;
+            float accelerationLoopRightLeft_;
+
+            float speed;
+            float rotate;
+            float loop;
+            float mouseY;
+            float mouseX;
+            float maxMouseX;
+            float minMouseX;
+            bool moved;
+
+            int emitterRate_;
+    };
+}
+
+#endif /* _Fighter_H__ */
Index: /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.cc	(revision 1545)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreRoot.h>
+#include <OgreRenderWindow.h>
+
+#include <string>
+
+#include "../Orxonox.h"
+#include "../GraphicsEngine.h"
+#include "util/tinyxml/tinyxml.h"
+#include "util/Tokenizer.h"
+#include "util/String2Number.h"
+#include "core/CoreIncludes.h"
+#include "SpaceshipSteeringObject.h"
+
+#include "../SpaceshipSteering.h"
+
+namespace orxonox
+{
+    CreateFactory(SpaceshipSteeringObject);
+
+    SpaceshipSteeringObject::SpaceshipSteeringObject()
+    {
+        RegisterObject(SpaceshipSteeringObject);
+    }
+
+    SpaceshipSteeringObject::~SpaceshipSteeringObject()
+    {
+    }
+
+    void SpaceshipSteeringObject::loadParams(TiXmlElement* xmlElem)
+    {
+      SpaceshipSteering* steering = orxonox::Orxonox::getSingleton()->getSteeringPointer();
+
+      if (xmlElem->Attribute("node") && xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
+      {
+        std::string nodeStr = xmlElem->Attribute("node");
+        std::string forwardStr = xmlElem->Attribute("forward");
+        std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");
+        std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");
+        std::string looprightleftStr = xmlElem->Attribute("looprightleft");
+
+        float forward, rotateupdown, rotaterightleft, looprightleft;
+        String2Number<float>(forward, forwardStr);
+        String2Number<float>(rotateupdown, rotateupdownStr);
+        String2Number<float>(rotaterightleft, rotaterightleftStr);
+        String2Number<float>(looprightleft, looprightleftStr);
+
+        steering = new SpaceshipSteering(forward, rotateupdown, rotaterightleft, looprightleft);
+
+        Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
+        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(nodeStr);
+
+        steering->addNode(sceneNode);
+
+
+
+
+        COUT(4) << "Loader: Initialized spaceship steering at node " << nodeStr << " values "<< forward << " " << rotateupdown << " "<< rotaterightleft << " "<< looprightleft << " "<< std::endl << std::endl;
+      }
+   }
+}
Index: /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/SpaceshipSteeringObject.h	(revision 1545)
@@ -0,0 +1,24 @@
+#ifndef _OBJECT_SPACESHIPSTEERING_H__
+#define _OBJECT_SPACESHIPSTEERING_H__
+
+#include "core/BaseObject.h"
+#include "util/tinyxml/tinyxml.h"
+
+namespace orxonox
+{
+    class SpaceshipSteeringObject : public BaseObject
+    {
+        public:
+            SpaceshipSteeringObject();
+            virtual ~SpaceshipSteeringObject();
+
+
+            void loadParams(TiXmlElement* xmlElem);
+
+        private:
+
+
+    };
+}
+
+#endif
Index: /code/branches/network/src/asylum/orxonox/objects/Test.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/Test.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/Test.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _Test_H__
+#define _Test_H__
+
+#include "core/BaseObject.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    class Interface1 : virtual public OrxonoxClass
+    {
+        protected:
+            Interface1() { RegisterRootObject(Interface1); }
+    };
+
+    class Interface2 : virtual public OrxonoxClass
+    {
+        protected:
+            Interface2() { RegisterRootObject(Interface2); }
+    };
+
+    class A1 : public BaseObject
+    {
+        public:
+            A1() { RegisterObject(A1); }
+    };
+
+    class A2 : public BaseObject
+    {
+        public:
+            A2() { RegisterObject(A2); }
+    };
+
+    class A3: public BaseObject, public Interface1
+    {
+        public:
+            A3() { RegisterObject(A3); }
+    };
+
+    class A1B1 : public A1
+    {
+        public:
+            A1B1() { RegisterObject(A1B1); }
+    };
+
+    class A1B2 : public A1
+    {
+        public:
+            A1B2() { RegisterObject(A1B2); }
+//            virtual void test() = 0;
+    };
+
+    class A2B1 : public A2
+    {
+        public:
+            A2B1() { RegisterObject(A2B1); }
+    };
+
+    class A2B2 : public A2, Interface1
+    {
+        public:
+            A2B2() { RegisterObject(A2B2); }
+    };
+
+    class A3B1 : public A3
+    {
+        public:
+            A3B1() { RegisterObject(A3B1); }
+    };
+
+    class A3B2 : public A3, Interface2
+    {
+        public:
+            A3B2() { RegisterObject(A3B2); }
+    };
+
+    class A1B1C1 : public A1B1
+    {
+        public:
+            A1B1C1() { RegisterObject(A1B1C1); }
+    };
+
+    class A1B1C2 : public A1B1
+    {
+        public:
+            A1B1C2() { RegisterObject(A1B1C2); }
+    };
+
+    class A1B2C1 : public A1B2
+    {
+        public:
+            A1B2C1() { RegisterObject(A1B2C1); }
+//            void test() { std::cout << "test!\n"; }
+    };
+
+    class A2B1C1 : public A2B1, Interface2
+    {
+        public:
+            A2B1C1() { RegisterObject(A2B1C1); }
+    };
+
+    class A2B2C1 : public A2B2
+    {
+        public:
+            A2B2C1() { RegisterObject(A2B2C1); }
+    };
+
+    class A3B1C1 : public A3B1
+    {
+        public:
+            A3B1C1() { RegisterObject(A3B1C1); }
+    };
+
+    class A3B1C2 : public A3B1, Interface2
+    {
+        public:
+            A3B1C2() { RegisterObject(A3B1C2); }
+    };
+
+    class A3B2C1 : public A3B2
+    {
+        public:
+            A3B2C1() { RegisterObject(A3B2C1); }
+    };
+
+    class A3B2C2 : public A3B2
+    {
+        public:
+            A3B2C2() { RegisterObject(A3B2C2); }
+    };
+
+    CreateFactory(A1);
+    CreateFactory(A2);
+    CreateFactory(A3);
+    CreateFactory(A1B1);
+    CreateFactory(A1B2);
+    CreateFactory(A2B1);
+    CreateFactory(A2B2);
+    CreateFactory(A3B1);
+    CreateFactory(A3B2);
+    CreateFactory(A1B1C1);
+    CreateFactory(A1B1C2);
+    CreateFactory(A1B2C1);
+    CreateFactory(A2B1C1);
+    CreateFactory(A2B2C1);
+    CreateFactory(A3B1C1);
+    CreateFactory(A3B1C2);
+    CreateFactory(A3B2C1);
+    CreateFactory(A3B2C2);
+}
+
+#endif
Index: /code/branches/network/src/asylum/orxonox/objects/test1.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test1.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test1.cc	(revision 1545)
@@ -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 "test1.h"
+#include "test2.h"
+#include "test3.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(Test1);
+
+    Test1::Test1()
+    {
+        RegisterObject(Test1);
+
+        this->usefullClass1_ = Class(Test1);
+        this->usefullClass2_ = Class(Test2);
+        this->usefullClass3_ = Class(Test3);
+    }
+
+    Test1::~Test1()
+    {
+    }
+
+    void Test1::tick(float dt)
+    {
+        std::cout << "Test1: " << this << std::endl;
+    }
+
+    bool Test1::usefullClass1isA(Identifier* identifier)
+    {
+        return this->usefullClass1_->isA(identifier);
+    }
+
+    bool Test1::usefullClass2isA(Identifier* identifier)
+    {
+        return this->usefullClass2_->isA(identifier);
+    }
+
+    bool Test1::usefullClass3isA(Identifier* identifier)
+    {
+        return this->usefullClass3_.isA(identifier);
+    }
+
+    void Test1::setUsefullClass1(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test1: usefullClass1->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test1: usefullClass1->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test1: usefullClass1->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass1_ = identifier;
+    }
+
+    void Test1::setUsefullClass2(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test1: usefullClass2->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test1: usefullClass2->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test1: usefullClass2->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass2_ = identifier;
+    }
+
+    void Test1::setUsefullClassOfTypeTest3(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test1: usefullClass3->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test1: usefullClass3->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test1: usefullClass3->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass3_ = identifier;
+    }
+
+    void Test1::loadParams(TiXmlElement* xmlElem)
+    {
+
+
+
+    }
+}
Index: /code/branches/network/src/asylum/orxonox/objects/test1.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test1.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test1.h	(revision 1545)
@@ -0,0 +1,36 @@
+#ifndef _Test1_H__
+#define _Test1_H__
+
+#include "core/BaseObject.h"
+#include "Tickable.h"
+#include "test3.h"
+#include "util/tinyxml/tinyxml.h"
+
+namespace orxonox
+{
+    class Test1 : public BaseObject, public Tickable
+    {
+        public:
+            Test1();
+            virtual ~Test1();
+
+            virtual void tick(float dt);
+
+            bool usefullClass1isA(Identifier* identifier);
+            bool usefullClass2isA(Identifier* identifier);
+            bool usefullClass3isA(Identifier* identifier);
+            void setUsefullClass1(Identifier* identifier);
+            void setUsefullClass2(Identifier* identifier);
+            void setUsefullClassOfTypeTest3(Identifier* identifier);
+
+            void loadParams(TiXmlElement* xmlElem);
+
+        private:
+            Identifier* usefullClass1_;
+            Identifier* usefullClass2_;
+            SubclassIdentifier<Test3> usefullClass3_;
+
+    };
+}
+
+#endif
Index: /code/branches/network/src/asylum/orxonox/objects/test2.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test2.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test2.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "test1.h"
+#include "test2.h"
+#include "test3.h"
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+
+namespace orxonox
+{
+    CreateFactory(Test2);
+
+    Test2::Test2()
+    {
+        RegisterObject(Test2);
+
+        this->usefullClass1_ = Class(Test1);
+        this->usefullClass2_ = Class(Test2);
+        this->usefullClass3_ = Class(Test3);
+
+        timer1.setTimer(1, true, this, createExecutor(createFunctor(&Test2::timerFunction1)));
+        timer2.setTimer(5, true, this, createExecutor(createFunctor(&Test2::timerFunction2)));
+        timer3.setTimer(10, false, this, createExecutor(createFunctor(&Test2::timerFunction3)));
+    }
+
+    Test2::~Test2()
+    {
+    }
+
+    void Test2::timerFunction1()
+    {
+        std::cout << "Test2: 1 Sekunde" << std::endl;
+    }
+
+    void Test2::timerFunction2()
+    {
+        std::cout << "Test2: 5 Sekunden" << std::endl;
+    }
+
+    void Test2::timerFunction3()
+    {
+        std::cout << "Test2: 10 Sekunden sind um!" << std::endl;
+    }
+
+    bool Test2::usefullClass1isA(Identifier* identifier)
+    {
+        return this->usefullClass1_->isA(identifier);
+    }
+
+    bool Test2::usefullClass2isA(Identifier* identifier)
+    {
+        return this->usefullClass2_->isA(identifier);
+    }
+
+    bool Test2::usefullClass3isA(Identifier* identifier)
+    {
+        return this->usefullClass3_.isA(identifier);
+    }
+
+    void Test2::setUsefullClass1(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test2: usefullClass1->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test2: usefullClass1->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test2: usefullClass1->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass1_ = identifier;
+    }
+
+    void Test2::setUsefullClass2(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test2: usefullClass2->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test2: usefullClass2->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test2: usefullClass2->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass2_ = identifier;
+    }
+
+    void Test2::setUsefullClassOfTypeTest3(Identifier* identifier)
+    {
+        std::cout << std::endl;
+        std::cout << "Test2: usefullClass3->isA(Class(Test1)): " << identifier->isA(Class(Test1)) << std::endl;
+        std::cout << "Test2: usefullClass3->isA(Class(Test2)): " << identifier->isA(Class(Test2)) << std::endl;
+        std::cout << "Test2: usefullClass3->isA(Class(Test3)): " << identifier->isA(Class(Test3)) << std::endl;
+        this->usefullClass3_ = identifier;
+    }
+}
Index: /code/branches/network/src/asylum/orxonox/objects/test2.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test2.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test2.h	(revision 1545)
@@ -0,0 +1,39 @@
+#ifndef _Test2_H__
+#define _Test2_H__
+
+#include "core/BaseObject.h"
+#include "../tools/Timer.h"
+
+namespace orxonox
+{
+    class Test3;
+
+    class Test2 : public BaseObject
+    {
+        public:
+            Test2();
+            virtual ~Test2();
+
+            bool usefullClass1isA(Identifier* identifier);
+            bool usefullClass2isA(Identifier* identifier);
+            bool usefullClass3isA(Identifier* identifier);
+            void setUsefullClass1(Identifier* identifier);
+            void setUsefullClass2(Identifier* identifier);
+            void setUsefullClassOfTypeTest3(Identifier* identifier);
+
+            void timerFunction1();
+            void timerFunction2();
+            void timerFunction3();
+
+        private:
+            Identifier* usefullClass1_;
+            Identifier* usefullClass2_;
+            SubclassIdentifier<Test3> usefullClass3_;
+
+            Timer<Test2> timer1;
+            Timer<Test2> timer2;
+            Timer<Test2> timer3;
+    };
+}
+
+#endif
Index: /code/branches/network/src/asylum/orxonox/objects/test3.cc
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test3.cc	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test3.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "test1.h"
+#include "test2.h"
+#include "test3.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(Test3);
+
+    Test3::Test3()
+    {
+        RegisterObject(Test3);
+
+        this->setConfigValues();
+    }
+
+    void Test3::setConfigValues()
+    {
+        SetConfigValue(value_int_, 1);
+        SetConfigValue(value_uint_, 1);
+        SetConfigValue(value_char_, 1);
+        SetConfigValue(value_uchar_, 1);
+        SetConfigValue(value_float_, 1);
+        SetConfigValue(value_double_, 1);
+        SetConfigValue(value_bool_, 1);
+        SetConfigValue(value_string_, "This is a test");
+        SetConfigValue(value_constchar_, "This is another test");
+        SetConfigValue(value_vector2_, Vector2(101, 202));
+        SetConfigValue(value_vector3_, Vector3(13, 26, 39));
+        SetConfigValue(value_colourvalue_, ColourValue(1.0, 0.5, 0.25, 0.887));
+        SetConfigValueVector(vector_int_, std::vector<int>(1, 13));
+        SetConfigValueVector(vector_string_, std::vector<std::string>(3, "nothing"));
+        SetConfigValueVector(vector_vector3_, std::vector<Vector3>(1, Vector3(3, 2, 1)));
+    }
+
+    Test3::~Test3()
+    {
+    }
+
+    void Test3::configOutput()
+    {
+        std::cout << "int:             " << this->value_int_ << std::endl;
+        std::cout << "uint:            " << this->value_uint_ << std::endl;
+        std::cout << "char:            " << (int)this->value_char_ << std::endl;
+        std::cout << "uchar:           " << (int)this->value_uchar_ << std::endl;
+        std::cout << "float:           " << this->value_float_ << std::endl;
+        std::cout << "double:          " << this->value_double_ << std::endl;
+        std::cout << "bool:            " << this->value_bool_ << std::endl;
+        std::cout << "string:         >" << this->value_string_ << "<" << std::endl;
+        std::cout << "constchar:      >" << this->value_constchar_ << "<" << std::endl;
+        std::cout << "vector2:         " << this->value_vector2_ << std::endl;
+        std::cout << "vector3:         " << this->value_vector3_ << std::endl;
+        std::cout << "colourvalue:     " << this->value_colourvalue_ << std::endl;
+        std::cout << std::endl;
+        for (unsigned int i = 0; i < this->vector_int_.size(); i++)
+        std::cout << "vector<int>:     " << i << ": " << this->vector_int_[i] << std::endl;
+        for (unsigned int i = 0; i < this->vector_string_.size(); i++)
+        std::cout << "vector<string>:  " << i << ":>" << this->vector_string_[i] << "<" << std::endl;
+        for (unsigned int i = 0; i < this->vector_vector3_.size(); i++)
+        std::cout << "vector<vector3>: " << i << ": " << this->vector_vector3_[i] << std::endl;
+
+        ModifyConfigValue(value_int_, tset, "100");
+        std::cout << std::endl;
+        std::cout << "int:             " << this->value_int_ << std::endl;
+
+        ModifyConfigValue(value_int_, update);
+        std::cout << std::endl;
+        std::cout << "int:             " << this->value_int_ << std::endl;
+    }
+
+    #define testandcout(code) \
+      std::cout << #code << " " << code << std::endl
+
+    void Test3::usefullClassesIsATest(Test1* test1)
+    {
+        std::cout << std::endl;
+        std::cout << "Test1:" << std::endl;
+        testandcout(test1->usefullClass1isA(Class(Test1)));
+        testandcout(test1->usefullClass1isA(Class(Test2)));
+        testandcout(test1->usefullClass1isA(Class(Test3)));
+        std::cout << std::endl;
+        testandcout(test1->usefullClass2isA(Class(Test1)));
+        testandcout(test1->usefullClass2isA(Class(Test2)));
+        testandcout(test1->usefullClass2isA(Class(Test3)));
+        std::cout << std::endl;
+        testandcout(test1->usefullClass3isA(Class(Test1)));
+        testandcout(test1->usefullClass3isA(Class(Test2)));
+        testandcout(test1->usefullClass3isA(Class(Test3)));
+    }
+
+    void Test3::usefullClassesIsATest(Test2* test2)
+    {
+        std::cout << std::endl;
+        std::cout << "Test2:" << std::endl;
+        testandcout(test2->usefullClass1isA(Class(Test1)));
+        testandcout(test2->usefullClass1isA(Class(Test2)));
+        testandcout(test2->usefullClass1isA(Class(Test3)));
+        std::cout << std::endl;
+        testandcout(test2->usefullClass2isA(Class(Test1)));
+        testandcout(test2->usefullClass2isA(Class(Test2)));
+        testandcout(test2->usefullClass2isA(Class(Test3)));
+        std::cout << std::endl;
+        testandcout(test2->usefullClass3isA(Class(Test1)));
+        testandcout(test2->usefullClass3isA(Class(Test2)));
+        testandcout(test2->usefullClass3isA(Class(Test3)));
+    }
+}
Index: /code/branches/network/src/asylum/orxonox/objects/test3.h
===================================================================
--- /code/branches/network/src/asylum/orxonox/objects/test3.h	(revision 1545)
+++ /code/branches/network/src/asylum/orxonox/objects/test3.h	(revision 1545)
@@ -0,0 +1,47 @@
+#ifndef _Test3_H__
+#define _Test3_H__
+
+#include <vector>
+
+#include "core/BaseObject.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class Test1;
+    class Test2;
+
+    class Test3 : public BaseObject
+    {
+        public:
+            Test3();
+            virtual ~Test3();
+
+            void setConfigValues();
+
+            void usefullClassesIsATest(Test1* test1);
+            void usefullClassesIsATest(Test2* test2);
+
+            void configOutput();
+
+        private:
+            int                 value_int_;
+            unsigned int        value_uint_;
+            char                value_char_;
+            unsigned char       value_uchar_;
+            float               value_float_;
+            double              value_double_;
+            bool                value_bool_;
+            std::string         value_string_;
+            const char*         value_constchar_;
+            Vector2             value_vector2_;
+            Vector3             value_vector3_;
+            ColourValue         value_colourvalue_;
+
+            std::vector<int>         vector_int_;
+            std::vector<std::string> vector_string_;
+            std::vector<Vector3>     vector_vector3_;
+    };
+}
+
+#endif
Index: /code/branches/network/src/asylum/util/String2Number.h
===================================================================
--- /code/branches/network/src/asylum/util/String2Number.h	(revision 1545)
+++ /code/branches/network/src/asylum/util/String2Number.h	(revision 1545)
@@ -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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _String2Number_H__
+#define _String2Number_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+#include <iostream>
+
+#include "core/Debug.h"
+
+/**
+ * String to number conversion
+ *
+ * This class converts a number inside a std::string
+ * into a numeric type number (int,float,double)
+ * Number in string can be decimal, hexadecimal or octal
+ *
+ * @author Nicolas Perrenoud<nicolape_at_ee.ethz.ch>
+ *
+ * @example
+ * float f;
+ * String2Number<float>(f, std::string(" 123.45 "));
+ */
+
+template <class T>
+class String2Number
+{
+  private:
+  bool success_;
+
+  public:
+  /**
+   * Constructor
+   *
+   * First value is the target variable, the second vector is the
+   * string where the number is taken from, the third parameter
+   * should be one of std::hex, std::dec or std::oct (dec is default value)
+   */
+  inline String2Number(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) =  std::dec, int haltOnError=1)
+  {
+    std::istringstream iss(s);
+    success_ = !(iss >> f >> t).fail();
+
+    if (!success_ && haltOnError==1)
+    {
+      COUT(1) << "Error: Conversion from string to number in \"" << s << "\" failed." << std::endl;
+      exit(1);
+    }
+  }
+};
+
+#endif /* _String2Number_H__ */
Index: /code/branches/network/src/asylum/util/Tokenizer.h
===================================================================
--- /code/branches/network/src/asylum/util/Tokenizer.h	(revision 1545)
+++ /code/branches/network/src/asylum/util/Tokenizer.h	(revision 1545)
@@ -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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Tokenizer_H__
+#define _Tokenizer_H__
+
+#include <string>
+#include <iostream>
+#include <vector>
+
+/**
+ * String tokenizer
+ *
+ * Splits a given string into several smaller strings
+ * using a delmiter (default is the comma).
+ * Returns the result as a vector<string> object
+ *
+ * @author Nicolas Perrenoud<nicolape_at_ee.ethz.ch>
+ */
+
+inline std::vector<std::string> tokenize(const std::string& str, const std::string& delimiters = ",")
+{
+  std::vector<std::string> tokens;
+
+  // Skip delimiters at beginning.
+  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+  // Find first "non-delimiter".
+  std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
+
+  while (std::string::npos != pos || std::string::npos != lastPos)
+  {
+      // Found a token, add it to the vector.
+      tokens.push_back(str.substr(lastPos, pos - lastPos));
+      // Skip delimiters.  Note the "not_of"
+      lastPos = str.find_first_not_of(delimiters, pos);
+      // Find next "non-delimiter"
+      pos = str.find_first_of(delimiters, lastPos);
+  }
+  return tokens;
+}
+
+
+#endif /* _Tokenizer_H__ */
Index: /code/branches/network/src/audio/AudioBuffer.cc
===================================================================
--- /code/branches/network/src/audio/AudioBuffer.cc	(revision 1545)
+++ /code/branches/network/src/audio/AudioBuffer.cc	(revision 1545)
@@ -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/network/src/audio/AudioBuffer.h
===================================================================
--- /code/branches/network/src/audio/AudioBuffer.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioBuffer.h	(revision 1545)
@@ -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/network/src/audio/AudioIncludes.h
===================================================================
--- /code/branches/network/src/audio/AudioIncludes.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioIncludes.h	(revision 1545)
@@ -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:
+ *      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>
+
+#include "core/Error.h"
Index: /code/branches/network/src/audio/AudioManager.cc
===================================================================
--- /code/branches/network/src/audio/AudioManager.cc	(revision 1545)
+++ /code/branches/network/src/audio/AudioManager.cc	(revision 1545)
@@ -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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioManager.h"
+
+#include <AL/alut.h>
+
+#include "AudioBuffer.h"
+#include "AudioSource.h"
+#include "AudioStream.h"
+#include "core/Error.h"
+#include "core/Debug.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())
+			{
+    		orxonox::Error("Ogg refused to play.");
+			}
+			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())
+		            orxonox::Error("Ogg abruptly stopped.");
+		        else
+		            orxonox::Error("Ogg stream was interrupted.");
+
+		    }
+				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/network/src/audio/AudioManager.h
===================================================================
--- /code/branches/network/src/audio/AudioManager.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioManager.h	(revision 1545)
@@ -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:
+ *      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);
+
+		// Parses given xml string
+		void loadParams();
+
+		// 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/network/src/audio/AudioPrereqs.h
===================================================================
--- /code/branches/network/src/audio/AudioPrereqs.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioPrereqs.h	(revision 1545)
@@ -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/network/src/audio/AudioSource.cc
===================================================================
--- /code/branches/network/src/audio/AudioSource.cc	(revision 1545)
+++ /code/branches/network/src/audio/AudioSource.cc	(revision 1545)
@@ -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/network/src/audio/AudioSource.h
===================================================================
--- /code/branches/network/src/audio/AudioSource.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioSource.h	(revision 1545)
@@ -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/network/src/audio/AudioStream.cc
===================================================================
--- /code/branches/network/src/audio/AudioStream.cc	(revision 1545)
+++ /code/branches/network/src/audio/AudioStream.cc	(revision 1545)
@@ -0,0 +1,278 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/Debug.h"
+#include "core/Error.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)
+			{
+	    	orxonox::Error("Could not open Ogg file "+path);
+				return;
+			}
+
+	    if((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
+	    {
+        fclose(oggFile);
+	      orxonox::Error("Could not open Ogg stream. " + errorString(result));
+				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)
+	                orxonox::Error(errorString(result));
+	            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)
+			orxonox::Error("OpenAL error was raised.");
+	}
+
+
+
+	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/network/src/audio/AudioStream.h
===================================================================
--- /code/branches/network/src/audio/AudioStream.h	(revision 1545)
+++ /code/branches/network/src/audio/AudioStream.h	(revision 1545)
@@ -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
+{
+  #define 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/network/src/audio/CMakeLists.txt
===================================================================
--- /code/branches/network/src/audio/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/audio/CMakeLists.txt	(revision 1545)
@@ -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/network/src/core/ArgumentCompleter.h
===================================================================
--- /code/branches/network/src/core/ArgumentCompleter.h	(revision 1545)
+++ /code/branches/network/src/core/ArgumentCompleter.h	(revision 1545)
@@ -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/network/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- /code/branches/network/src/core/ArgumentCompletionFunctions.cc	(revision 1545)
+++ /code/branches/network/src/core/ArgumentCompletionFunctions.cc	(revision 1545)
@@ -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/network/src/core/ArgumentCompletionFunctions.h
===================================================================
--- /code/branches/network/src/core/ArgumentCompletionFunctions.h	(revision 1545)
+++ /code/branches/network/src/core/ArgumentCompletionFunctions.h	(revision 1545)
@@ -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/network/src/core/ArgumentCompletionListElement.h
===================================================================
--- /code/branches/network/src/core/ArgumentCompletionListElement.h	(revision 1545)
+++ /code/branches/network/src/core/ArgumentCompletionListElement.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionListElement_H__
+#define _ArgumentCompletionListElement_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#define ACL_MODE_NORMAL    1
+#define ACL_MODE_LOWERCASE 2
+#define ACL_MODE_DISPLAY   4
+
+namespace orxonox
+{
+    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/network/src/core/BaseObject.cc
===================================================================
--- /code/branches/network/src/core/BaseObject.cc	(revision 1545)
+++ /code/branches/network/src/core/BaseObject.cc	(revision 1545)
@@ -0,0 +1,93 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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() :
+      bActive_(true),
+      bVisible_(true),
+      level_(0),
+      namespace_(0)
+    {
+        RegisterRootObject(BaseObject);
+    }
+
+    /**
+        @brief Destructor
+    */
+    BaseObject::~BaseObject()
+    {
+    }
+
+    /**
+        @brief load general xml paramters
+    */
+    void BaseObject::loadParams(TiXmlElement* xmlElem)
+    {
+        if (xmlElem->Attribute("name"))
+        {
+            this->setName(xmlElem->Attribute("name"));
+        }
+    }
+
+    /**
+        @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);
+    }
+
+    /**
+        @brief Returns the levelfile that loaded this object.
+        @return The levelfile
+    */
+    const std::string& BaseObject::getLevelfile() const
+    {
+        return this->level_->getFile();
+    }
+}
Index: /code/branches/network/src/core/BaseObject.h
===================================================================
--- /code/branches/network/src/core/BaseObject.h	(revision 1545)
+++ /code/branches/network/src/core/BaseObject.h	(revision 1545)
@@ -0,0 +1,100 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "util/XMLIncludes.h"
+#include "OrxonoxClass.h"
+
+namespace orxonox
+{
+    //! The BaseObject is the parent of all classes representing an instance in the game.
+    class _CoreExport BaseObject : virtual public OrxonoxClass
+    {
+        public:
+            BaseObject();
+            virtual ~BaseObject();
+            virtual void loadParams(TiXmlElement* xmlElem);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            /** @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 setActivity(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }
+            /** @brief Returns the state of the objects activity. @return The state of the activity */
+            inline const 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 setVisibility(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
+            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
+            inline const 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 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_;
+    };
+}
+
+#endif /* _BaseObject_H__ */
Index: /code/branches/network/src/core/CMakeLists.txt
===================================================================
--- /code/branches/network/src/core/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/core/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,73 @@
+SET(CORE_SRC_FILES
+  ConfigFileManager.cc
+  ConfigValueContainer.cc
+  Core.cc
+  Error.cc
+  Language.cc
+  OrxonoxClass.cc
+  OutputBuffer.cc
+  OutputHandler.cc
+  Script.cc
+  SignalHandler.cc
+
+  # command
+  ArgumentCompletionFunctions.cc
+  CommandEvaluation.cc
+  CommandExecutor.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/HalfAxis.cc
+  input/InputBuffer.cc
+  input/InputCommands.cc
+  input/InputManager.cc
+  input/KeyBinder.cc
+  input/KeyDetector.cc
+
+  tolua/tolua_bind.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h
+  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
+  tinyxml
+  tolualib
+  ois
+  util
+  ${Boost_thread_LIBRARIES}
+  ${Boost_filesystem_LIBRARIES}
+)
Index: /code/branches/network/src/core/ClassFactory.h
===================================================================
--- /code/branches/network/src/core/ClassFactory.h	(revision 1545)
+++ /code/branches/network/src/core/ClassFactory.h	(revision 1545)
@@ -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 "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()->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/network/src/core/ClassTreeMask.cc
===================================================================
--- /code/branches/network/src/core/ClassTreeMask.cc	(revision 1545)
+++ /code/branches/network/src/core/ClassTreeMask.cc	(revision 1545)
@@ -0,0 +1,855 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 Tells if the rule is "included" or not.
+        @return The rule: true = included, false = excluded
+    */
+    bool ClassTreeMaskNode::isIncluded() const
+    {
+        return this->bIncluded_;
+    }
+
+    /**
+        @brief Tells if the rule is "excluded" or not.
+        @return The inverted rule: true = excluded, false = included
+    */
+    bool ClassTreeMaskNode::isExcluded() const
+    {
+        return (!this->bIncluded_);
+    }
+
+    /**
+        @brief Returns the Identifier of the class the rule refers to.
+        @return The Identifier representing the class
+    */
+    const Identifier* ClassTreeMaskNode::getClass() const
+    {
+        return this->subclass_;
+    }
+
+    /**
+        @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
+    */
+    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()
+    {
+        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)
+    {
+        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)
+    {
+        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
+    */
+    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
+    */
+    ClassTreeMask& ClassTreeMask::operator+()
+    {
+        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
+    */
+    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
+    */
+    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
+    */
+    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
+    */
+    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
+    */
+    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
+    */
+    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;
+    }
+}
Index: /code/branches/network/src/core/ClassTreeMask.h
===================================================================
--- /code/branches/network/src/core/ClassTreeMask.h	(revision 1545)
+++ /code/branches/network/src/core/ClassTreeMask.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+    @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 childs of BaseObject, A1 and A2 are childs of A, B1 and B2 are childs 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>
+
+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;
+
+        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);
+
+            bool isIncluded() const;
+            bool isExcluded() const;
+
+            const Identifier* getClass() const;
+
+        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();
+
+            ClassTreeMaskIterator& operator++();
+            ClassTreeMaskNode* operator*() const;
+            ClassTreeMaskNode* operator->() const;
+            operator bool();
+            bool operator==(ClassTreeMaskNode* compare);
+            bool operator!=(ClassTreeMaskNode* compare);
+
+        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
+    {
+        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;
+
+            ClassTreeMask& operator=(const ClassTreeMask& other);
+
+            bool operator==(const ClassTreeMask& other) const;
+            bool operator!=(const ClassTreeMask& other) const;
+
+            ClassTreeMask& operator+();
+            ClassTreeMask operator-() const;
+
+            ClassTreeMask operator+(const ClassTreeMask& other) const;
+            ClassTreeMask operator*(const ClassTreeMask& other) const;
+            ClassTreeMask operator-(const ClassTreeMask& other) const;
+            ClassTreeMask operator!() const;
+
+            ClassTreeMask& operator+=(const ClassTreeMask& other);
+            ClassTreeMask& operator*=(const ClassTreeMask& other);
+            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;
+
+            ClassTreeMask& operator&=(const ClassTreeMask& other);
+            ClassTreeMask& operator|=(const ClassTreeMask& other);
+            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
+    };
+}
+
+#endif /* _ClassTreeMask_H__ */
Index: /code/branches/network/src/core/CommandEvaluation.cc
===================================================================
--- /code/branches/network/src/core/CommandEvaluation.cc	(revision 1545)
+++ /code/branches/network/src/core/CommandEvaluation.cc	(revision 1545)
@@ -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 "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(4) << "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, MultiTypeMath param)
+    {
+        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+            this->param_[index] = param;
+    }
+
+    MultiTypeMath 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;
+    }
+
+    MultiTypeMath CommandEvaluation::getReturnvalue() const
+    {
+        if (this->function_)
+            return this->function_->getReturnvalue();
+
+        return MultiTypeMath();
+    }
+
+
+    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).toString() + "]";
+            else
+                output += "}";
+        }
+        return output;
+    }
+}
Index: /code/branches/network/src/core/CommandEvaluation.h
===================================================================
--- /code/branches/network/src/core/CommandEvaluation.h	(revision 1545)
+++ /code/branches/network/src/core/CommandEvaluation.h	(revision 1545)
@@ -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/MultiTypeMath.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, MultiTypeMath param);
+            MultiTypeMath getEvaluatedParameter(unsigned int index) const;
+
+            bool hasReturnvalue() const;
+            MultiTypeMath 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_;
+            MultiTypeMath param_[5];
+    };
+}
+
+#endif /* _CommandEvaluation_H__ */
Index: /code/branches/network/src/core/CommandExecutor.cc
===================================================================
--- /code/branches/network/src/core/CommandExecutor.cc	(revision 1545)
+++ /code/branches/network/src/core/CommandExecutor.cc	(revision 1545)
@@ -0,0 +1,650 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/Convert.h"
+#include "Identifier.h"
+#include "Language.h"
+#include "Debug.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/network/src/core/CommandExecutor.h
===================================================================
--- /code/branches/network/src/core/CommandExecutor.h	(revision 1545)
+++ /code/branches/network/src/core/CommandExecutor.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _CommandExecutor_H__
+#define _CommandExecutor_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+
+#include "CommandEvaluation.h"
+
+namespace orxonox
+{
+    class _CoreExport CommandExecutor
+    {
+        public:
+            static bool execute(const std::string& command, bool useTcl = true);
+            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_;
+    };
+}
+
+#endif /* _CommandExecutor_H__ */
Index: /code/branches/network/src/core/ConfigFileManager.cc
===================================================================
--- /code/branches/network/src/core/ConfigFileManager.cc	(revision 1545)
+++ /code/branches/network/src/core/ConfigFileManager.cc	(revision 1545)
@@ -0,0 +1,562 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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"
+
+#define CONFIG_FILE_MAX_LINELENGHT 1024
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(config).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(tconfig).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(reloadConfig);
+    SetConsoleCommandShortcutExtern(cleanConfig);
+    SetConsoleCommandShortcutExtern(loadSettings).setArgumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(loadKeybindings).setArgumentCompleter(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::getSingleton()->load();
+    }
+
+    void cleanConfig()
+    {
+        ConfigFileManager::getSingleton()->clean(false);
+    }
+
+    void loadSettings(const std::string& filename)
+    {
+        ConfigFileManager::getSingleton()->setFile(CFT_Settings, filename, false);
+    }
+
+    void loadKeybindings(const std::string& filename)
+    {
+        ConfigFileManager::getSingleton()->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(3) << "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::getSingleton()
+    {
+        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/network/src/core/ConfigFileManager.h
===================================================================
--- /code/branches/network/src/core/ConfigFileManager.h	(revision 1545)
+++ /code/branches/network/src/core/ConfigFileManager.h	(revision 1545)
@@ -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"
+
+#define DEFAULT_CONFIG_FILE "default.ini"
+
+namespace orxonox
+{
+    enum _CoreExport ConfigFileType
+    {
+        CFT_Settings,
+        CFT_Keybindings
+    };
+
+
+    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* getSingleton();
+
+            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/network/src/core/ConfigValueContainer.cc
===================================================================
--- /code/branches/network/src/core/ConfigValueContainer.cc	(revision 1545)
+++ /code/branches/network/src/core/ConfigValueContainer.cc	(revision 1545)
@@ -0,0 +1,355 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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"
+
+#define MAX_VECTOR_INDEX 255 // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument
+
+
+namespace orxonox
+{
+    /**
+        @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
+    */
+    ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue)
+    {
+        this->type_ = type;
+        this->identifier_ = identifier;
+        this->sectionname_ = identifier->getName();
+        this->varname_ = varname;
+
+        this->value_ = defvalue;
+        this->bAddedDescription_ = false;
+        this->bIsVector_ = false;
+
+        this->defvalueString_ = defvalue.toString();
+        this->update();
+    }
+
+    /**
+        @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
+    */
+    ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue)
+    {
+        this->type_ = type;
+        this->identifier_ = identifier;
+        this->sectionname_ = identifier->getName();
+        this->varname_ = varname;
+
+        this->valueVector_ = defvalue;
+        this->bAddedDescription_ = false;
+        this->bIsVector_ = true;
+
+        if (defvalue.size() > 0)
+        {
+                this->value_ = defvalue[0];
+
+            for (unsigned int i = 0; i < defvalue.size(); i++)
+            {
+                ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string));
+                this->defvalueStringVector_.push_back(defvalue[i].toString());
+            }
+
+            this->update();
+        }
+    }
+
+    /**
+        @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 MultiTypeMath& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::set, input.toString());
+        }
+        else
+        {
+            if (this->tset(input))
+            {
+                ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, input.toString(), this->value_.isA(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 MultiTypeMath& input)
+    {
+        if (this->bIsVector_)
+        {
+            if (this->tset(index, input))
+            {
+                ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, index, input.toString(), this->value_.isA(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 MultiTypeMath& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::tset, input.toString());
+        }
+        else
+        {
+            MultiTypeMath temp = this->value_;
+            if (temp.assimilate(input))
+            {
+                this->value_ = temp;
+                if (this->identifier_)
+                    this->identifier_->updateConfigValues();
+
+                return true;
+            }
+        }
+        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 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 MultiTypeMath& 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(MultiTypeMath());
+                }
+            }
+
+            MultiTypeMath temp = this->value_;
+            if (temp.assimilate(input))
+            {
+                this->valueVector_[index] = temp;
+
+                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 MultiTypeMath& 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::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string));
+                ConfigFileManager::getSingleton()->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::getSingleton()->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_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isA(MT_string)));
+        else
+        {
+            this->valueVector_.clear();
+            for (unsigned int i = 0; i < ConfigFileManager::getSingleton()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
+            {
+                if (i < this->defvalueStringVector_.size())
+                {
+                    this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isA(MT_string)));
+                }
+                else
+                {
+                    this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiTypeMath(), this->value_.isA(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 MultiTypeMath&), 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 > 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
+    */
+    void 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;
+        }
+    }
+
+    /**
+        @brief Returns the description of the config-value.
+        @return The description
+    */
+    const std::string& ConfigValueContainer::getDescription() const
+    {
+        return GetLocalisation(this->description_);
+    }
+}
Index: /code/branches/network/src/core/ConfigValueContainer.h
===================================================================
--- /code/branches/network/src/core/ConfigValueContainer.h	(revision 1545)
+++ /code/branches/network/src/core/ConfigValueContainer.h	(revision 1545)
@@ -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:
+ *      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/MultiTypeMath.h"
+#include "ConfigFileManager.h"
+
+namespace orxonox
+{
+    //! 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:
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue);
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue);
+
+            /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */
+            template <typename T>
+            inline ConfigValueContainer& getValue(T* value)
+                { this->value_.getValue(value); return *this; }
+            template <typename T>
+            inline ConfigValueContainer& getValue(std::vector<T>* value)
+            {
+                value->clear();
+                for (unsigned int i = 0; i < this->valueVector_.size(); i++)
+                    value->push_back(this->valueVector_[i]);
+                return *this;
+            }
+
+            template <typename T>
+            inline void setVectorType(const std::vector<T>& value)
+            {
+                this->value_ = T();
+                this->update();
+            }
+
+            inline const std::string& getName() const
+                { return this->varname_; }
+            inline bool isVector() const
+                { return this->bIsVector_; }
+            inline unsigned int getVectorSize() const
+                { return this->valueVector_.size(); }
+
+            void description(const std::string& description);
+            const std::string& getDescription() const;
+
+            bool set(const MultiTypeMath& input);
+            bool tset(const MultiTypeMath& input);
+
+            bool set(unsigned int index, const MultiTypeMath& input);
+            bool tset(unsigned int index, const MultiTypeMath& input);
+            bool add(const MultiTypeMath& 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_.toString(); }
+            /** @brief Returns the typename of the assigned config-value. @return The typename */
+            inline std::string getTypename() const
+                { return this->value_.getTypename(); }
+
+        private:
+            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), 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
+
+            MultiTypeMath              value_;                      //!< The value
+            std::vector<MultiTypeMath> 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
+    };
+}
+
+#endif /* _ConfigValueContainer_H__ */
Index: /code/branches/network/src/core/ConfigValueIncludes.h
===================================================================
--- /code/branches/network/src/core/ConfigValueIncludes.h	(revision 1545)
+++ /code/branches/network/src/core/ConfigValueIncludes.h	(revision 1545)
@@ -0,0 +1,124 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 SetConfigValue(varname, defvalue) \
+    orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, varname = defvalue); \
+        this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname)
+
+/**
+    @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 classname name in which the config value should be stored
+    @param varname The name of the variable
+    @param defvalue The default-value of the variable
+*/
+#define SetConfigValueGeneric(classname, varname, defvalue) \
+    orxonox::ConfigValueContainer* container##varname = ClassIdentifier<classname>::getIdentifier()->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, ClassIdentifier<classname>::getIdentifier(), #varname, varname = defvalue); \
+        ClassIdentifier<classname>::getIdentifier()->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname)
+
+/**
+    @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 SetConfigValueVector(varname, defvalue) \
+    orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        std::vector<MultiTypeMath> temp; \
+        for (unsigned int i = 0; i < defvalue.size(); i++) \
+            temp.push_back(MultiTypeMath(defvalue[i])); \
+        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, temp); \
+        container##varname->setVectorType(varname); \
+        this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname)
+
+/**
+    @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); \
+    } \
+    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); \
+    } \
+    else \
+    { \
+        COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+    }
+
+#endif /* _ConfigValueIncludes_H__ */
Index: /code/branches/network/src/core/ConsoleCommand.cc
===================================================================
--- /code/branches/network/src/core/ConsoleCommand.cc	(revision 1545)
+++ /code/branches/network/src/core/ConsoleCommand.cc	(revision 1545)
@@ -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(FunctorStatic* functor, const std::string& name) : ExecutorStatic(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::setArgumentCompleter(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/network/src/core/ConsoleCommand.h
===================================================================
--- /code/branches/network/src/core/ConsoleCommand.h	(revision 1545)
+++ /code/branches/network/src/core/ConsoleCommand.h	(revision 1545)
@@ -0,0 +1,143 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "ClassManager.h"
+#include "CommandExecutor.h"
+#include "ArgumentCompletionFunctions.h"
+
+
+#define SetConsoleCommand(classname, function,  bCreateShortcut) \
+    SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut)
+
+#define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \
+    orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier()->addConsoleCommand(command, bCreateShortcut)
+
+
+#define SetConsoleCommandShortcut(classname, function) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function))
+
+#define SetConsoleCommandShortcutExtern(function) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function))
+
+#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 ExecutorStatic
+    {
+        public:
+            ConsoleCommand(FunctorStatic* functor, const std::string& name = "");
+
+            inline ConsoleCommand& setDescription(const std::string& description)
+                { this->ExecutorStatic::setDescription(description); return (*this); }
+            inline ConsoleCommand& setDescriptionParam(int param, const std::string& description)
+                { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); }
+            inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description)
+                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
+            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1)
+                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
+            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
+                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
+            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
+                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
+            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
+                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
+            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
+                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
+            inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param)
+                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
+
+            inline ConsoleCommand& setAccessLevel(AccessLevel::Level level)
+                { this->accessLevel_ = level; return (*this); }
+            inline AccessLevel::Level getAccessLevel() const
+                { return this->accessLevel_; }
+
+            ConsoleCommand& setArgumentCompleter(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& setKeybindMode(KeybindMode::Enum mode)
+                { this->keybindMode_ = mode; return *this; }
+            inline KeybindMode::Enum getKeybindMode() const
+                { return this->keybindMode_; }
+
+            inline ConsoleCommand& setAxisParamIndex(int index)
+                { this->axisParamIndex_ = index; return *this; }
+            inline int getAxisParamIndex() const
+                { return this->axisParamIndex_; }
+
+            inline ConsoleCommand& setIsAxisRelative(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(FunctorStatic* functor, const std::string& name = "")
+    {
+        return new ConsoleCommand(functor, name);
+    }
+}
+
+#endif /* _ConsoleCommand_H__ */
Index: /code/branches/network/src/core/ConsoleCommandCompilation.cc
===================================================================
--- /code/branches/network/src/core/ConsoleCommandCompilation.cc	(revision 1545)
+++ /code/branches/network/src/core/ConsoleCommandCompilation.cc	(revision 1545)
@@ -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 "Debug.h"
+#include "util/ExprParser.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(source).setArgumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(echo);
+    SetConsoleCommandShortcutExtern(puts);
+
+    SetConsoleCommandShortcutExtern(read).setArgumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(append).setArgumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(write).setArgumentCompleter(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/network/src/core/ConsoleCommandCompilation.h
===================================================================
--- /code/branches/network/src/core/ConsoleCommandCompilation.h	(revision 1545)
+++ /code/branches/network/src/core/ConsoleCommandCompilation.h	(revision 1545)
@@ -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/network/src/core/Core.cc
===================================================================
--- /code/branches/network/src/core/Core.cc	(revision 1545)
+++ /code/branches/network/src/core/Core.cc	(revision 1545)
@@ -0,0 +1,209 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 Core.cc
+    @brief Implementation of the Core class.
+*/
+
+#include "Core.h"
+#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();
+    }
+
+    /**
+        @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;
+        static bool bFirstTime = true;
+        if (bFirstTime)
+        {
+            bFirstTime = false;
+            Core::getInstance();
+        }
+        return bCreatingCoreSettings;
+    }
+
+    /**
+        @brief Returns a unique instance of Core.
+        @return The instance
+    */
+    Core& Core::getInstance()
+    {
+        static Core instance = Core();
+
+        // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
+        if (Core::isCreatingCoreSettings())
+        {
+            isCreatingCoreSettings() = false;
+            instance.setConfigValues();
+        }
+        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");
+        SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile");
+        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell");
+
+        // 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_;
+
+
+        std::string temp = this->language_;
+        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text");
+
+        if (this->language_ != temp)
+        {
+            // 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())
+        {
+            if (device == OutputHandler::LD_All)
+                return Core::getInstance().softDebugLevel_;
+            else if (device == OutputHandler::LD_Console)
+                return Core::getInstance().softDebugLevelConsole_;
+            else if (device == OutputHandler::LD_Logfile)
+                return Core::getInstance().softDebugLevelLogfile_;
+            else if (device == OutputHandler::LD_Shell)
+                return Core::getInstance().softDebugLevelShell_;
+        }
+
+        // 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;
+        }
+     }
+
+    /**
+        @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::tick(dt);
+    }
+}
+
+/**
+    @brief Returns the soft debug level, stored in the only existing instance of the DebugLevel class, configured in the config-file.
+    @return The soft debug level
+*/
+int getSoftDebugLevel()
+{
+    return orxonox::Core::getSoftDebugLevel();
+}
Index: /code/branches/network/src/core/Core.h
===================================================================
--- /code/branches/network/src/core/Core.h	(revision 1545)
+++ /code/branches/network/src/core/Core.h	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Core.h
+    @brief Definition 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 "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();
+
+            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/network/src/core/CoreIncludes.h
===================================================================
--- /code/branches/network/src/core/CoreIncludes.h	(revision 1545)
+++ /code/branches/network/src/core/CoreIncludes.h	(revision 1545)
@@ -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 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 "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()->registerClass(this->getParents(), #ClassName, bRootClass)); \
+    if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \
+        this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
+    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this); \
+    if (orxonox::Identifier::isCreatingHierarchy()) \
+      return
+
+/**
+    @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 ID(StringOrInt) \
+    orxonox::Factory::getIdentifier(StringOrInt)
+
+#endif /* _CoreIncludes_H__ */
Index: /code/branches/network/src/core/CorePrereqs.h
===================================================================
--- /code/branches/network/src/core/CorePrereqs.h	(revision 1545)
+++ /code/branches/network/src/core/CorePrereqs.h	(revision 1545)
@@ -0,0 +1,177 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+//-----------------------------------------------------------------------
+class SignalHandler;
+
+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 CommandEvaluation;
+  class CommandExecutor;
+  class ConfigFile;
+  class ConfigFileEntry;
+  class ConfigFileEntryComment;
+  class ConfigFileEntryValue;
+  class ConfigFileManager;
+  class ConfigFileSection;
+  class ConfigValueContainer;
+  class ConsoleCommand;
+  class Core;
+  class Error;
+  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 Language;
+  class LanguageEntry;
+  class Level;
+  class Loader;
+  class MetaObjectList;
+  template <class T>
+  class MetaObjectListElement;
+  class Namespace;
+  class NamespaceNode;
+  template <class T>
+  class ObjectList;
+  template <class T>
+  class ObjectListElement;
+  class OrxonoxClass;
+  class OutputBuffer;
+  class OutputBufferListener;
+  class OutputHandler;
+  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;
+
+  // input
+  //class GUIInputHandler;
+  class BaseCommand;
+  class BufferedParamCommand;
+  class Button;
+  class CalibratorCallback;
+  class HalfAxis;
+  class InputBuffer;
+  class InputManager;
+  class JoyStickHandler;
+  class MouseHandler;
+  class KeyBinder;
+  class KeyDetector;
+  class KeyHandler;
+  class ParamCommand;
+  class SimpleCommand;
+}
+
+#endif /* _CorePrereqs_H__ */
Index: /code/branches/network/src/core/Debug.h
===================================================================
--- /code/branches/network/src/core/Debug.h	(revision 1545)
+++ /code/branches/network/src/core/Debug.h	(revision 1545)
@@ -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:
+ *      Benjamin Grauer
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+/**
+ * @file Debug.h
+ * @brief Handles the output for different verbose-modes.
+ *
+ * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime.
+ */
+
+#ifndef _Debug_H__
+#define _Debug_H__
+
+#include "CorePrereqs.h"
+
+#include <stdio.h>
+
+#include "OutputHandler.h"
+
+extern "C" _CoreExport int 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_vDEBUG          5
+
+//definitions
+#define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting
+
+#define ORX_HARD_DEBUG_LEVEL ORX_vDEBUG
+//#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting
+
+///////////////////////////////////////////////////
+/// PRINTF: prints with filename and linenumber ///
+///////////////////////////////////////////////////
+#define PRINTFORX_NONE    PRINTF0
+#define PRINTFORX_ERROR   PRINTF1
+#define PRINTFORX_WARNING PRINTF2
+#define PRINTFORX_INFO    PRINTF3
+#define PRINTFORX_DEBUG   PRINTF4
+#define PRINTFORX_vDEBUG  PRINTF5
+
+#define PRINT_EXEC  printf
+#define COUT_EXEC(x) \
+  orxonox::OutputHandler::getOutStream().setOutputLevel(x)
+
+#ifndef PRINTF
+ #if ORX_PRINT_DEBUG_OUTPUT
+
+  #define PRINTF(x) \
+   PRINTF ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define PRINTF1 \
+    if (getSoftDebugLevel() >= ORX_ERROR) \
+     printf("Error (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
+  #else
+   #define PRINTF1 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define PRINTF2 \
+    if (getSoftDebugLevel() >= ORX_WARNING) \
+     printf("Warning (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
+  #else
+   #define PRINTF2 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define PRINTF3 \
+    if (getSoftDebugLevel() >= ORX_INFO) \
+     printf("Info (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
+  #else
+   #define PRINTF3 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define PRINTF4 \
+    if (getSoftDebugLevel() >= ORX_DEBUG) \
+     printf("Debug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
+  #else
+   #define PRINTF4 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
+   #define PRINTF5 \
+    if (getSoftDebugLevel() >= ORX_vDEBUG) \
+     printf("vDebug (in %s, line %d): ", __FILE__, __LINE__), PRINT_EXEC
+  #else
+   #define PRINTF5 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define PRINTF(x) if (ORX_NONE) PRINT_EXEC
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+ #define PRINTF0 \
+  PRINT_EXEC
+#endif /* ifndef PRINTF */
+
+///////////////////////////////////////////////////
+///  PRINT: just prints output as is            ///
+///////////////////////////////////////////////////
+#define PRINTORX_NONE    PRINT0
+#define PRINTORX_ERROR   PRINT1
+#define PRINTORX_WARNING PRINT2
+#define PRINTORX_INFO    PRINT3
+#define PRINTORX_DEBUG   PRINT4
+#define PRINTORX_vDEBUG  PRINT5
+
+#ifndef PRINT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define PRINT(x) \
+   PRINT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define PRINT1  \
+    if (getSoftDebugLevel() >= ORX_ERROR)  \
+     PRINT_EXEC
+  #else
+   #define PRINT1 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define PRINT2 \
+    if (getSoftDebugLevel() >= ORX_WARNING) \
+     PRINT_EXEC
+  #else
+   #define PRINT2 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define PRINT3 \
+    if (getSoftDebugLevel() >= ORX_INFO) \
+     PRINT_EXEC
+  #else
+   #define PRINT3 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define PRINT4 \
+    if (getSoftDebugLevel() >= ORX_DEBUG) \
+     PRINT_EXEC
+  #else
+   #define PRINT4 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
+   #define PRINT5 \
+    if (getSoftDebugLevel() >= ORX_vDEBUG) \
+     PRINT_EXEC
+  #else
+   #define PRINT5 if (ORX_NONE) PRINT_EXEC
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define PRINT(x) if (ORX_NONE) PRINT_EXEC
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+ #define PRINT0 \
+  PRINT_EXEC
+#endif /* ifndef PRINT */
+
+
+////////////////////////////////////////////////////////
+///  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_vDEBUG  COUT5
+
+#ifndef COUT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define COUT(x) \
+   COUT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
+   #define COUT0  \
+    if (getSoftDebugLevel() >= ORX_NONE)  \
+     COUT_EXEC(0)
+  #else
+   #define COUT0 if (ORX_NONE)\
+    COUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define COUT1  \
+    if (getSoftDebugLevel() >= ORX_ERROR)  \
+     COUT_EXEC(1)
+  #else
+   #define COUT1 if (ORX_NONE)\
+    COUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define COUT2 \
+    if (getSoftDebugLevel() >= ORX_WARNING) \
+     COUT_EXEC(2)
+  #else
+   #define COUT2 if (ORX_NONE) \
+    COUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define COUT3 \
+    if (getSoftDebugLevel() >= ORX_INFO) \
+     COUT_EXEC(3)
+  #else
+   #define COUT3 if (ORX_NONE) \
+    COUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define COUT4 \
+    if (getSoftDebugLevel() >= ORX_DEBUG) \
+     COUT_EXEC(4)
+  #else
+   #define COUT4 if (ORX_NONE) \
+    COUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
+   #define COUT5 \
+    if (getSoftDebugLevel() >= ORX_vDEBUG) \
+     COUT_EXEC(5)
+  #else
+   #define COUT5 if (ORX_NONE) \
+    COUT_EXEC(5)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define COUT(x) if (ORX_NONE) \
+   COUT_EXEC(5)
+ #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_vDEBUG  CCOUT5
+
+#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  \
+    if (getSoftDebugLevel() >= ORX_NONE)  \
+     CCOUT_EXEC(0)
+  #else
+   #define CCOUT0 if (ORX_NONE)\
+    CCOUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define CCOUT1  \
+    if (getSoftDebugLevel() >= ORX_ERROR)  \
+     CCOUT_EXEC(1)
+  #else
+   #define CCOUT1 if (ORX_NONE)\
+    CCOUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define CCOUT2 \
+    if (getSoftDebugLevel() >= ORX_WARNING) \
+     CCOUT_EXEC(2)
+  #else
+   #define CCOUT2 if (ORX_NONE) \
+    CCOUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define CCOUT3 \
+    if (getSoftDebugLevel() >= ORX_INFO) \
+     CCOUT_EXEC(3)
+  #else
+   #define CCOUT3 if (ORX_NONE) \
+    CCOUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define CCOUT4 \
+    if (getSoftDebugLevel() >= ORX_DEBUG) \
+     CCOUT_EXEC(4)
+  #else
+   #define CCOUT4 if (ORX_NONE) \
+    CCOUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_vDEBUG
+   #define CCOUT5 \
+    if (getSoftDebugLevel() >= ORX_vDEBUG) \
+     CCOUT_EXEC(5)
+  #else
+   #define CCOUT5 if (ORX_NONE) \
+    CCOUT_EXEC(5)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define CCOUT(x) if (ORX_NONE) \
+   CCOUT_EXEC(5)
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+#endif /* ifndef CCOUT */
+
+#endif /* _Debug_H__ */
Index: /code/branches/network/src/core/Error.cc
===================================================================
--- /code/branches/network/src/core/Error.cc	(revision 1545)
+++ /code/branches/network/src/core/Error.cc	(revision 1545)
@@ -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:
+ *      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/network/src/core/Error.h
===================================================================
--- /code/branches/network/src/core/Error.h	(revision 1545)
+++ /code/branches/network/src/core/Error.h	(revision 1545)
@@ -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 "CorePrereqs.h"
+
+#include <string>
+
+namespace orxonox
+{
+	class _CoreExport Error
+	{
+	public:
+		Error(std::string errorMsg = "", int errorCode = 0);
+	private:
+
+	};
+}
+
+#endif /* _Error_H__ */
Index: /code/branches/network/src/core/Executor.cc
===================================================================
--- /code/branches/network/src/core/Executor.cc	(revision 1545)
+++ /code/branches/network/src/core/Executor.cc	(revision 1545)
@@ -0,0 +1,251 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "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, MultiTypeMath 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(int param, const std::string& description)
+    {
+        if (param >= 0 && param < MAX_FUNCTOR_ARGUMENTS)
+        {
+            if (!this->bAddedDescriptionParam_[param])
+            {
+                std::string paramnumber;
+                if (!Convert::ToString(&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(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 MultiTypeMath& param1)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& 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 MultiTypeMath& 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/network/src/core/Executor.h
===================================================================
--- /code/branches/network/src/core/Executor.h	(revision 1545)
+++ /code/branches/network/src/core/Executor.h	(revision 1545)
@@ -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 "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) MultiTypeMath(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; \
+            } \
+        } \
+        \
+        MultiTypeMath 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 MultiTypeMath& param1) const
+                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2) const
+                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
+                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
+                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& 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, MultiTypeMath param[5], const std::string& delimiter = " ") const;
+
+            Executor& setDescription(const std::string& description);
+            const std::string& getDescription() const;
+
+            Executor& setDescriptionParam(int param, const std::string& description);
+            const std::string& getDescriptionParam(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 MultiTypeMath 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 MultiTypeMath& param1);
+            Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2);
+            Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3);
+            Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4);
+            Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5);
+            Executor& setDefaultValue(unsigned int index, const MultiTypeMath& param);
+
+            inline MultiTypeMath 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_;
+            MultiTypeMath 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 MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& 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 MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& 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/network/src/core/Factory.cc
===================================================================
--- /code/branches/network/src/core/Factory.cc	(revision 1545)
+++ /code/branches/network/src/core/Factory.cc	(revision 1545)
@@ -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 "Debug.h"
+#include "BaseObject.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/network/src/core/Factory.h
===================================================================
--- /code/branches/network/src/core/Factory.h	(revision 1545)
+++ /code/branches/network/src/core/Factory.h	(revision 1545)
@@ -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/network/src/core/Functor.h
===================================================================
--- /code/branches/network/src/core/Functor.h	(revision 1545)
+++ /code/branches/network/src/core/Functor.h	(revision 1545)
@@ -0,0 +1,475 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/MultiTypeMath.h"
+#include "Debug.h"
+
+#define MAX_FUNCTOR_ARGUMENTS 5
+
+namespace orxonox
+{
+    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(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 MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& 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 MultiTypeMath 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, MultiTypeMath& param) const = 0;
+
+        protected:
+            unsigned int numParams_;
+            bool hasReturnValue_;
+            FunctionType type_;
+            MultiTypeMath returnedValue_;
+
+            std::string typeReturnvalue_;
+            std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport FunctorStatic : public Functor
+    {
+        public:
+            virtual ~FunctorStatic() {}
+            virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& 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 MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
+            virtual void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
+
+            virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& 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) { P1 temp = param; param = temp; }
+#define FUNCTOR_EVALUATE_PARAM2 \
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; }
+#define FUNCTOR_EVALUATE_PARAM3 \
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; }
+#define FUNCTOR_EVALUATE_PARAM4 \
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; } \
+    else if (index == 3) { P4 temp = param; param = temp; }
+#define FUNCTOR_EVALUATE_PARAM5 \
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; } \
+    else if (index == 3) { P4 temp = param; param = temp; } \
+    else if (index == 4) { P5 temp = param; param = temp; }
+
+
+
+
+
+#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 MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiTypeMath& 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 MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& 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, MultiTypeMath& 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 MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiTypeMath& 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/network/src/core/IRC.cc
===================================================================
--- /code/branches/network/src/core/IRC.cc	(revision 1545)
+++ /code/branches/network/src/core/IRC.cc	(revision 1545)
@@ -0,0 +1,141 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <boost/thread/thread.hpp>
+
+#include "IRC.h"
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+#include "CoreIncludes.h"
+#include "util/Convert.h"
+
+#define IRC_TCL_THREADID 1421421421
+
+namespace orxonox
+{
+    SetConsoleCommand(IRC, say,  true).setAccessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, msg,  false).setAccessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, nick, false).setAccessLevel(AccessLevel::User);
+
+    IRC* instance_irc = &IRC::getInstance();
+
+    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/network/src/core/IRC.h
===================================================================
--- /code/branches/network/src/core/IRC.h	(revision 1545)
+++ /code/branches/network/src/core/IRC.h	(revision 1545)
@@ -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/network/src/core/Identifier.cc
===================================================================
--- /code/branches/network/src/core/Identifier.cc	(revision 1545)
+++ /code/branches/network/src/core/Identifier.cc	(revision 1545)
@@ -0,0 +1,360 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "ConsoleCommand.h"
+#include "CommandExecutor.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->bCreatedOneObject_ = 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_;
+    }
+
+    /**
+        @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::getIdentifier(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 isn't an entry yet, put the proposal in it
+            identifiers[name] = proposal;
+        }
+        else
+        {
+            // this happens when a template exists twice --> delete the proposal
+            delete proposal;
+        }
+        return identifiers[name];
+    }
+
+    /**
+        @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);
+            }
+        }
+    }
+
+    /**
+        @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;
+        }
+
+        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;
+        }
+
+        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 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/network/src/core/Identifier.h
===================================================================
--- /code/branches/network/src/core/Identifier.h	(revision 1545)
+++ /code/branches/network/src/core/Identifier.h	(revision 1545)
@@ -0,0 +1,618 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "ObjectList.h"
+#include "Debug.h"
+#include "Iterator.h"
+#include "MetaObjectList.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 childs
+         - 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 ClassIdentifier;
+
+        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;
+
+            virtual const ObjectList<BaseObject>* getObjectList() const = 0;
+
+            virtual void updateConfigValues() const = 0;
+
+            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
+            inline const std::string& getName() const { return this->name_; }
+
+
+            /** @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);
+
+            virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
+            virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0;
+
+            virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;
+            virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0;
+
+            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
+            ConsoleCommand* getConsoleCommand(const std::string& name) const;
+            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
+
+        protected:
+            /** @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();
+
+        private:
+            Identifier();
+            Identifier(const Identifier& identifier); // don't copy
+            virtual ~Identifier();
+            void initialize(std::set<const Identifier*>* parents);
+
+            /** @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_); }
+
+            /**
+                @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 Identifier* getIdentifier(std::string &name, Identifier *proposal);
+
+            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
+
+            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)
+            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
+            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
+    };
+
+    _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
+    {
+        public:
+            ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass);
+            void addObject(T* object);
+            void setName(const std::string& name);
+            /** @brief Returns the list of all existing objects of this class. @return The list */
+            inline ObjectList<T>* getObjects() const { return this->objects_; }
+            /** @brief Returns a list of all existing objects of this class. @return The list */
+            inline ObjectList<BaseObject>* getObjectList() const { return (ObjectList<BaseObject>*)this->objects_; }
+
+            void updateConfigValues() const;
+
+            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
+            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
+
+            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
+            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
+
+            static ClassIdentifier<T> *getIdentifier();
+
+        private:
+            ClassIdentifier();
+            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
+            ~ClassIdentifier() {}                                       // don't delete
+
+            ObjectList<T>* objects_;                                                                    //!< The ObjectList, containing all objects of type T
+            bool bSetName_;                                                                             //!< True if the name is set
+            std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;              //!< All loadable parameters
+            std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;   //!< All attachable objects
+
+            static ClassIdentifier<T> *classIdentifier_s;
+    };
+
+    template <class T>
+    ClassIdentifier<T> *ClassIdentifier<T>::classIdentifier_s = 0;
+
+    /**
+        @brief Constructor: Creates the ObjectList.
+    */
+    template <class T>
+    ClassIdentifier<T>::ClassIdentifier()
+    {
+//        this->objects_ = ObjectList<T>::getList();
+        this->objects_ = new ObjectList<T>();
+        this->bSetName_ = false;
+    }
+
+    /**
+        @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 name A string, containing exactly the name of the class
+        @param bRootClass True if the class is either an Interface or the BaseObject itself
+        @return The ClassIdentifier itself
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass)
+    {
+        this->setName(name);
+
+        // 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 " << name << "-Singleton -> Initialize Singleton." << std::endl;
+            if (bRootClass)
+                this->initialize(NULL); // 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);
+        }
+
+        return this;
+    }
+
+    /**
+        @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name.
+        @return The unique Identifier
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+    {
+        // check if the static field has already been filled
+        if (ClassIdentifier<T>::classIdentifier_s == 0)
+        {
+            // 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::getIdentifier(name, proposal);
+        }
+
+        // Finally return the unique ClassIdentifier
+        return ClassIdentifier<T>::classIdentifier_s;
+    }
+
+    /**
+        @brief Sets the name of the class.
+        @param name The name
+    */
+    template <class T>
+    void ClassIdentifier<T>::setName(const std::string& name)
+    {
+        if (!this->bSetName_)
+        {
+            this->name_ = name;
+            this->bSetName_ = true;
+            Identifier::getIdentifierMapIntern()[name] = this;
+            Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
+        }
+    }
+
+    /**
+        @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(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() const
+    {
+        for (Iterator<T> it = this->objects_->start(); it; ++it)
+            ((T*)*it)->setConfigValues();
+    }
+
+    /**
+        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
+        @param paramname The name of the parameter
+        @return The container
+    */
+    template <class T>
+    XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname)
+    {
+        typename std::map<std::string, XMLPortClassParamContainer<T>*>::const_iterator it = xmlportParamContainers_.find(paramname);
+        if (it != xmlportParamContainers_.end())
+            return (XMLPortParamContainer*)((*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
+    */
+    template <class T>
+    void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
+    {
+        this->xmlportParamContainers_[paramname] = (XMLPortClassParamContainer<T>*)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
+    */
+    template <class T>
+    XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname)
+    {
+        typename std::map<std::string, XMLPortClassObjectContainer<T, class O>*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
+        if (it != xmlportObjectContainers_.end())
+            return (XMLPortObjectContainer*)((*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
+    */
+    template <class T>
+    void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
+    {
+        this->xmlportObjectContainers_[sectionname] = (XMLPortClassObjectContainer<T, class O>*)container;
+    }
+
+
+    // ###############################
+    // ###   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/network/src/core/Iterator.h
===================================================================
--- /code/branches/network/src/core/Iterator.h	(revision 1545)
+++ /code/branches/network/src/core/Iterator.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+    @file Iterator.h
+    @brief Definition and implementation of the Iterator class.
+
+    The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
+    This is the only way to access the objects stored in an ObjectList.
+
+    Usage:
+    for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
+    {
+        it->someFunction(...);
+        class* myObject = *it;
+    }
+
+    Warning: Don't delete objects directly through the iterator.
+*/
+
+#ifndef _Iterator_H__
+#define _Iterator_H__
+
+#include "CorePrereqs.h"
+
+#include "ObjectList.h"
+
+namespace orxonox
+{
+    //! The iterator allows to iterate through an ObjectList of a given class.
+    template <class T>
+    class Iterator
+    {
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to zero.
+            */
+            Iterator()
+            {
+                this->element_ = 0;
+                ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to a given element.
+                @param element The element to start with
+            */
+            Iterator(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
+            }
+
+            /**
+                @brief Unregisters the Iterator from the ObjectList.
+            */
+            ~Iterator()
+            {
+                ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this);
+            }
+
+            /**
+                @brief Assigns an element to the iterator.
+                @param element The element
+            */
+            Iterator<T> operator=(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+            }
+
+            /**
+                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            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
+            */
+            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
+            */
+            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
+            */
+            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
+            */
+            T* operator*()
+            {
+                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 Iterator points at
+            */
+            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 iterator points to an existing object.
+                @return True if the iterator points to an existing object.
+            */
+            operator bool()
+            {
+                return (this->element_ != 0);
+            }
+
+            /**
+                @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
+                @param compare The integer (must be zero, everything else makes no sense).
+                @return True if the iterator points to an existing object.
+            */
+            bool operator!=(ObjectListElement<T>* compare)
+            {
+                return (this->element_ != compare);
+            }
+
+        private:
+            ObjectListElement<T>* element_;     //!< The element the Iterator points at
+    };
+}
+
+#endif /* _Iterator_H__ */
Index: /code/branches/network/src/core/Language.cc
===================================================================
--- /code/branches/network/src/core/Language.cc	(revision 1545)
+++ /code/branches/network/src/core/Language.cc	(revision 1545)
@@ -0,0 +1,322 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "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 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/network/src/core/Language.h
===================================================================
--- /code/branches/network/src/core/Language.h	(revision 1545)
+++ /code/branches/network/src/core/Language.h	(revision 1545)
@@ -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() {};                 // don't delete
+
+            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/network/src/core/Level.h
===================================================================
--- /code/branches/network/src/core/Level.h	(revision 1545)
+++ /code/branches/network/src/core/Level.h	(revision 1545)
@@ -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/network/src/core/Loader.cc
===================================================================
--- /code/branches/network/src/core/Loader.cc	(revision 1545)
+++ /code/branches/network/src/core/Loader.cc	(revision 1545)
@@ -0,0 +1,180 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "Debug.h"
+#include "CoreIncludes.h"
+#include "Script.h"
+#include "Namespace.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)
+    {
+        Loader::levels_s.insert(Loader::levels_s.end(), std::pair<const Level*, ClassTreeMask>(level, mask));
+    }
+
+    void Loader::remove(const Level* level)
+    {
+        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 (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )
+        {
+            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)
+    {
+        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->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)
+    {
+        for (Iterator<BaseObject> 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/network/src/core/Loader.h
===================================================================
--- /code/branches/network/src/core/Loader.h	(revision 1545)
+++ /code/branches/network/src/core/Loader.h	(revision 1545)
@@ -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/network/src/core/MetaObjectList.cc
===================================================================
--- /code/branches/network/src/core/MetaObjectList.cc	(revision 1545)
+++ /code/branches/network/src/core/MetaObjectList.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+    @file MetaObjectList.cc
+    @brief Implementation of the MetaObjectList class.
+*/
+
+#include "MetaObjectList.h"
+
+namespace orxonox
+{
+    /**
+        @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()
+    {
+        BaseMetaObjectListElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+}
Index: /code/branches/network/src/core/MetaObjectList.h
===================================================================
--- /code/branches/network/src/core/MetaObjectList.h	(revision 1545)
+++ /code/branches/network/src/core/MetaObjectList.h	(revision 1545)
@@ -0,0 +1,142 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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"
+
+#include "ObjectList.h"
+#include "Identifier.h"
+#include "Debug.h"
+
+namespace orxonox
+{
+    //! Base-class of MetaObjectListElement, because those is a template
+    class BaseMetaObjectListElement
+    {
+        public:
+            /** @brief Default destructor */
+            virtual ~BaseMetaObjectListElement() {};
+
+            BaseMetaObjectListElement* next_;       //!< The next Element in the list
+    };
+
+    // ###############################
+    // ###  MetaObjectListElement  ###
+    // ###############################
+    //! The list-element of the MetaObjectList
+    template <class T>
+    class MetaObjectListElement : public BaseMetaObjectListElement
+    {
+        public:
+            MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element);
+            virtual ~MetaObjectListElement();
+
+            ObjectListElement<T>* element_;         //!< The list element, containing the object
+            ObjectList<T>* list_;                   //!< The list, containing the element
+    };
+
+    /**
+        @brief Constructor: Creates the list-element with given list and element.
+    */
+    template <class T>
+    MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)
+    {
+        this->element_ = element;
+        this->list_ = list;
+        this->next_ = 0;
+    }
+
+    /**
+        @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.
+    */
+    template <class T>
+    MetaObjectListElement<T>::~MetaObjectListElement()
+    {
+        COUT(5) << "*** MetaObjectList: Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;
+        this->list_->notifyIterators(this->element_);
+
+        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      ###
+    // ###############################
+    //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
+    /**
+        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();
+            template <class T>
+            void add(ObjectList<T>* list, ObjectListElement<T>* element);
+
+            BaseMetaObjectListElement* first_;      //!< The first element in the list
+    };
+
+    /**
+        @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
+    */
+    template <class T>
+    void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)
+    {
+        BaseMetaObjectListElement* temp = this->first_;
+        this->first_ = new MetaObjectListElement<T>(list, element);
+        this->first_->next_ = temp;
+    }
+}
+
+#endif /* _MetaObjectList_H__ */
Index: /code/branches/network/src/core/Namespace.cc
===================================================================
--- /code/branches/network/src/core/Namespace.cc	(revision 1545)
+++ /code/branches/network/src/core/Namespace.cc	(revision 1545)
@@ -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)
+    {
+        BaseObject::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/network/src/core/Namespace.h
===================================================================
--- /code/branches/network/src/core/Namespace.h	(revision 1545)
+++ /code/branches/network/src/core/Namespace.h	(revision 1545)
@@ -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/network/src/core/NamespaceNode.cc
===================================================================
--- /code/branches/network/src/core/NamespaceNode.cc	(revision 1545)
+++ /code/branches/network/src/core/NamespaceNode.cc	(revision 1545)
@@ -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 "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/network/src/core/NamespaceNode.h
===================================================================
--- /code/branches/network/src/core/NamespaceNode.h	(revision 1545)
+++ /code/branches/network/src/core/NamespaceNode.h	(revision 1545)
@@ -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/network/src/core/ObjectList.h
===================================================================
--- /code/branches/network/src/core/ObjectList.h	(revision 1545)
+++ /code/branches/network/src/core/ObjectList.h	(revision 1545)
@@ -0,0 +1,184 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 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.
+    Use Iterator<class> to iterate through all objects of the class.
+*/
+
+#ifndef _ObjectList_H__
+#define _ObjectList_H__
+
+#include <set>
+
+#include "CorePrereqs.h"
+
+#include "Iterator.h"
+#include "Identifier.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###    ObjectListElement    ###
+    // ###############################
+    //! The list-element of the ObjectList
+    template <class T>
+    class ObjectListElement
+    {
+        public:
+            ObjectListElement(T* object);
+
+            T* object_;                     //!< The object
+            ObjectListElement* next_;       //!< The next element in the list
+            ObjectListElement* prev_;       //!< The previous element in the list
+    };
+
+    /**
+        @brief Constructor: Creates the list-element with an object.
+        @param object The object to store
+    */
+    template <class T>
+    ObjectListElement<T>::ObjectListElement(T* object)
+    {
+        this->object_ = object;
+        this->next_ = 0;
+        this->prev_ = 0;
+    }
+
+
+    // ###############################
+    // ###       ObjectList        ###
+    // ###############################
+    //! The ObjectList contains all objects of a given class.
+    /**
+        The ObjectList is used by Identifiers to store all objects of a given class.
+        Use Iterator<class> to iterate through all objects in the list.
+    */
+    template <class T>
+    class ObjectList
+    {
+        public:
+            ObjectList();
+            ~ObjectList();
+
+            ObjectListElement<T>* add(T* object);
+
+            /** @brief Returns the first element in the list. @return The first element */
+            inline static Iterator<T> start()
+                { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
+
+            /** @brief Returns the first element in the list. @return The first element */
+            inline static Iterator<T> begin()
+                { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
+
+            /** @brief Returns the last element in the list. @return The last element */
+            inline static Iterator<T> end()
+                { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->last_); }
+
+            inline void registerIterator(Iterator<T>* iterator)
+                { this->iterators_.insert(this->iterators_.end(), (void*)iterator); }
+            inline void unregisterIterator(Iterator<T>* iterator)
+                { this->iterators_.erase((void*)iterator); }
+            void notifyIterators(ObjectListElement<T>* element);
+
+            ObjectListElement<T>* first_;       //!< The first element in the list
+            ObjectListElement<T>* last_;        //!< The last element in the list
+
+        private:
+            std::set<void*> iterators_;  //!< A list of iterators pointing on an element in this list
+    };
+
+    /**
+        @brief Constructor: Sets default values.
+    */
+    template <class T>
+    ObjectList<T>::ObjectList()
+    {
+        this->first_ = 0;
+        this->last_ = 0;
+    }
+
+    /**
+        @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
+    */
+    template <class T>
+    ObjectList<T>::~ObjectList()
+    {
+        ObjectListElement<T>* 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
+    */
+    template <class T>
+    void ObjectList<T>::notifyIterators(ObjectListElement<T>* element)
+    {
+        for (std::set<void*>::iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
+            if ((*(*((Iterator<T>*)(*it)))) == element->object_)
+                ++(*((Iterator<T>*)(*it)));
+    }
+
+    /**
+        @brief Adds a new object to the end of the list.
+        @param object The object to add
+        @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object
+    */
+    template <class T>
+    ObjectListElement<T>* ObjectList<T>::add(T* object)
+    {
+        if (!this->last_)
+        {
+            // If the list is empty
+            this->last_ = new ObjectListElement<T>(object);
+            this->first_ = this->last_; // There's only one object in the list now
+        }
+        else
+        {
+            // If the list isn't empty
+            ObjectListElement<T>* temp = this->last_;
+            this->last_ = new ObjectListElement<T>(object);
+            this->last_->prev_ = temp;
+            temp->next_ = this->last_;
+        }
+
+        return this->last_;
+    }
+}
+
+#endif /* _ObjectList_H__ */
Index: /code/branches/network/src/core/OrxonoxClass.cc
===================================================================
--- /code/branches/network/src/core/OrxonoxClass.cc	(revision 1545)
+++ /code/branches/network/src/core/OrxonoxClass.cc	(revision 1545)
@@ -0,0 +1,138 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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() :
+      identifier_(0),
+      parents_(0)
+    {
+        this->metaList_ = new MetaObjectList();
+
+        this->setConfigValues();
+    }
+
+    /** @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/network/src/core/OrxonoxClass.h
===================================================================
--- /code/branches/network/src/core/OrxonoxClass.h	(revision 1545)
+++ /code/branches/network/src/core/OrxonoxClass.h	(revision 1545)
@@ -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 Definition 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/network/src/core/OutputBuffer.cc
===================================================================
--- /code/branches/network/src/core/OutputBuffer.cc	(revision 1545)
+++ /code/branches/network/src/core/OutputBuffer.cc	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OutputBuffer.h"
+
+#define OUTPUTBUFFER_MAX_LINE_LENGTH 16384
+
+namespace orxonox
+{
+    void OutputBuffer::registerListener(OutputBufferListener* listener)
+    {
+        this->listeners_.insert(this->listeners_.end(), 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;
+        }
+    }
+
+    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    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);
+    }
+
+    void OutputBuffer::callListeners()
+    {
+        for (std::list<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+            (*it)->outputChanged();
+    }
+}
Index: /code/branches/network/src/core/OutputBuffer.h
===================================================================
--- /code/branches/network/src/core/OutputBuffer.h	(revision 1545)
+++ /code/branches/network/src/core/OutputBuffer.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _OutputBuffer_H__
+#define _OutputBuffer_H__
+
+#include <list>
+#include <sstream>
+#include <iostream>
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    class _CoreExport OutputBufferListener
+    {
+        friend class OutputBuffer;
+
+        public:
+            virtual ~OutputBufferListener() {}
+
+        private:
+            virtual void outputChanged() = 0;
+    };
+
+    class _CoreExport OutputBuffer
+    {
+        public:
+            OutputBuffer() {}
+            ~OutputBuffer() {}
+
+            template <class T>
+            inline OutputBuffer& operator<<(T object)
+            {
+                this->stream_ << object;
+                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&));
+
+            template <class T>
+            inline void add(T object)
+            {
+                this->stream_ << object;
+                this->callListeners();
+            }
+
+            template <class T>
+            inline void addLine(T object)
+            {
+                this->stream_ << object << std::endl;
+                this->callListeners();
+            }
+
+            inline void newline()
+            {
+                this->stream_ << std::endl;
+                this->callListeners();
+            }
+
+            inline void flush()
+            {
+                this->stream_.flush();
+            }
+
+            bool getLine(std::string* output);
+
+            void registerListener(OutputBufferListener* listener);
+            void unregisterListener(OutputBufferListener* listener);
+
+        private:
+            void callListeners();
+
+            std::stringstream stream_;
+            std::list<OutputBufferListener*> listeners_;
+    };
+}
+
+#endif /* _OutputBuffer_H__ */
Index: /code/branches/network/src/core/OutputHandler.cc
===================================================================
--- /code/branches/network/src/core/OutputHandler.cc	(revision 1545)
+++ /code/branches/network/src/core/OutputHandler.cc	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputHandler.cc
+    @brief Implementation of the OutputHandler class.
+*/
+
+#include "OutputHandler.h"
+#include "Core.h"
+#include "ConsoleCommand.h"
+#include "Shell.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutGeneric(log,     createConsoleCommand(createFunctor(&OutputHandler::log),     "log"    ));
+    SetConsoleCommandShortcutGeneric(error,   createConsoleCommand(createFunctor(&OutputHandler::error),   "error"  ));
+    SetConsoleCommandShortcutGeneric(warning, createConsoleCommand(createFunctor(&OutputHandler::warning), "warning"));
+    SetConsoleCommandShortcutGeneric(info,    createConsoleCommand(createFunctor(&OutputHandler::info),    "info"   ));
+    SetConsoleCommandShortcutGeneric(debug,   createConsoleCommand(createFunctor(&OutputHandler::debug),   "debug"  ));
+
+    /**
+        @brief Constructor: Opens the logfile and writes the first line.
+        @param logfilename The name of the logfile
+    */
+    OutputHandler::OutputHandler(const std::string& logfilename)
+    {
+        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;
+        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 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 Core::getSoftDebugLevel(device);
+    }
+
+    /**
+        @brief Returns the Shell's OutputBuffer. This is mere placed here to avoid
+               recompiling the entire project when Shell.h changes.
+        @return The OutputBuffer of the Shell
+    */
+    OutputBuffer& OutputHandler::getShellOutputBuffer()
+    {
+        return Shell::getInstance().getOutputBuffer();
+    }
+
+    /**
+        @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_)
+            Shell::getInstance().getOutputBuffer() << sb;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console and the logfile.
+        @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_)
+            Shell::getInstance().getOutputBuffer() << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console and the logfile.
+        @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_)
+            Shell::getInstance().getOutputBuffer() << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console and the logfile.
+        @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_)
+            Shell::getInstance().getOutputBuffer() << manipulator;
+
+        return *this;
+    }
+}
Index: /code/branches/network/src/core/OutputHandler.h
===================================================================
--- /code/branches/network/src/core/OutputHandler.h	(revision 1545)
+++ /code/branches/network/src/core/OutputHandler.h	(revision 1545)
@@ -0,0 +1,192 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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.
+*/
+
+#ifndef _OutputHandler_H__
+#define _OutputHandler_H__
+
+#include "CorePrereqs.h"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#include "OutputBuffer.h"
+
+namespace orxonox
+{
+    //! The OutputHandler acts like std::cout, but redirects output to the console AND the logfile.
+    class _CoreExport OutputHandler
+    {
+        public:
+            enum OutputDevice
+            {
+                LD_All,
+                LD_Console,
+                LD_Logfile,
+                LD_Shell
+            };
+
+            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 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 int getSoftDebugLevel(OutputHandler::OutputDevice device);
+
+            OutputBuffer& getShellOutputBuffer();
+
+            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<<(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
+            int outputLevel_;           //!< The level of the incoming output
+    };
+
+    /**
+        @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_)
+            OutputHandler::getOutStream().getShellOutputBuffer() << 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())
+            OutputHandler::getOutStream().getShellOutputBuffer() << output;
+
+        return out;
+    }
+
+}
+
+#endif /* _OutputHandler_H__ */
Index: /code/branches/network/src/core/Script.cc
===================================================================
--- /code/branches/network/src/core/Script.cc	(revision 1545)
+++ /code/branches/network/src/core/Script.cc	(revision 1545)
@@ -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++.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/network/src/core/Script.h
===================================================================
--- /code/branches/network/src/core/Script.h	(revision 1545)
+++ /code/branches/network/src/core/Script.h	(revision 1545)
@@ -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:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file  script.h
+ @brief Representation of an interface to lua
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _Script_H__
+#define _Script_H__
+
+#include "CorePrereqs.h"
+
+extern "C" {
+#include <lua.h>
+}
+
+#include <list>
+#include <string>
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+  class _CoreExport Script // tolua_export
+  { // 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_; };
+
+    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/network/src/core/Script_clean.h
===================================================================
--- /code/branches/network/src/core/Script_clean.h	(revision 1545)
+++ /code/branches/network/src/core/Script_clean.h	(revision 1545)
@@ -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:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file  script.h
+ @brief Representation of an interface to lua
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _Script_H__
+#define _Script_H__
+
+#include "CorePrereqs.h"
+
+extern "C" {
+#include <lua.h>
+}
+
+#include <list>
+#include <string>
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+  class  Script // tolua_export
+  { // tolua_export
+    public:
+      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
+      inline ~Script() { Script::singletonRef = NULL; };
+
+    void loadFile(std::string filename, bool luaTags);
+    //void init(lua_State *state_);
+    //void xmlToLua();
+    void run();
+    void luaPrint(std::string str); // tolua_export
+
+#if LUA_VERSION_NUM != 501
+    inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
+#endif
+
+    inline lua_State* getLuaState() { return luaState_; };
+    inline std::string getLuaOutput() { return output_; };
+    //inline std::string* getFileString() { return &fileString_; };
+
+    unsigned int getNextQuote(const std::string& text, unsigned int start);
+    std::string replaceLuaTags(const std::string& text);
+
+    private:
+      Script();
+      static Script* singletonRef;
+
+      std::string luaSource_;
+      std::string output_;
+      lua_State* luaState_;
+
+  }; // tolua_export
+} // tolua_export
+#endif /* _Script_H__ */
Index: /code/branches/network/src/core/Shell.cc
===================================================================
--- /code/branches/network/src/core/Shell.cc	(revision 1545)
+++ /code/branches/network/src/core/Shell.cc	(revision 1545)
@@ -0,0 +1,384 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "input/InputInterfaces.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);
+
+    Shell::Shell()
+    {
+        RegisterRootObject(Shell);
+
+        this->scrollPosition_ = 0;
+        this->maxHistoryLength_ = 100;
+        this->historyPosition_ = 0;
+        this->historyOffset_ = 0;
+        this->finishedLastLine_ = true;
+        this->bAddOutputLevel_ = false;
+
+        this->clearLines();
+
+        this->inputBuffer_ = 0;
+        this->setInputBuffer(new InputBuffer());
+
+        this->outputBuffer_.registerListener(this);
+
+        this->setConfigValues();
+    }
+
+    Shell& Shell::createShell()
+    {
+        int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell);
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
+        static Shell instance;
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
+        return instance;
+    }
+
+    Shell& Shell::getInstance()
+    {
+        static Shell& instance = createShell();
+        return instance;
+    }
+
+    void Shell::setConfigValues()
+    {
+        SetConfigValue(maxHistoryLength_, 100);
+        SetConfigValue(historyOffset_, 0);
+        SetConfigValueVector(commandHistory_, std::vector<std::string>());
+
+        if (this->historyOffset_ >= this->maxHistoryLength_)
+            this->historyOffset_ = 0;
+
+        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::setInputBuffer(InputBuffer* buffer)
+    {
+        if (this->inputBuffer_)
+        {
+            this->inputBuffer_->unregisterListener(this);
+            // TODO: may be very dangerous. InputManager already deletes InputBuffer instance!!!
+            delete this->inputBuffer_;
+        }
+
+        this->inputBuffer_ = buffer;
+        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/network/src/core/Shell.h
===================================================================
--- /code/branches/network/src/core/Shell.h	(revision 1545)
+++ /code/branches/network/src/core/Shell.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _Shell_H__
+#define _Shell_H__
+
+#include <list>
+#include <vector>
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "input/InputBuffer.h"
+#include "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:
+            static Shell& getInstance();
+            static Shell& createShell();
+
+            static void clearShell();
+            static void history();
+
+            virtual void setConfigValues();
+
+            void registerListener(ShellListener* listener);
+            void unregisterListener(ShellListener* listener);
+
+            void setInputBuffer(InputBuffer* buffer);
+            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();
+            Shell(const Shell& other);
+            virtual ~Shell() {}
+
+            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_;
+    };
+}
+
+#endif /* _Shell_H__ */
Index: /code/branches/network/src/core/SignalHandler.cc
===================================================================
--- /code/branches/network/src/core/SignalHandler.cc	(revision 1545)
+++ /code/branches/network/src/core/SignalHandler.cc	(revision 1545)
@@ -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 "SignalHandler.h"
+
+#include <assert.h>
+#include <iostream>
+
+#include "Debug.h"
+
+SignalHandler * SignalHandler::singletonRef = NULL;
+
+#ifndef __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);
+    }
+  }
+
+  PRINTF(0)( "recieved signal %s\ntry to write backtrace to file orxonox.log\n", sigName.c_str() );
+
+  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 )
+    {
+      PRINTF(0)("something went wrong :(\n");
+    }
+
+    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() )
+  {
+    PRINTF(0)( ( std::string("could not write %d byte to ") + getInstance()->fileName ).c_str(), bt.length());
+    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 /* __WIN32__ */
Index: /code/branches/network/src/core/SignalHandler.h
===================================================================
--- /code/branches/network/src/core/SignalHandler.h	(revision 1545)
+++ /code/branches/network/src/core/SignalHandler.h	(revision 1545)
@@ -0,0 +1,108 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 Definition of the SignalHandler class.
+*/
+
+#ifndef _SignalHandler_H__
+#define _SignalHandler_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+#include <string>
+
+typedef int (*SignalCallback)( void * someData );
+
+#ifndef __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 /* #ifndef __WIN32__ */
+
+class _CoreExport 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 /* #ifndef __WIN32__ */
+
+#endif /* _SignalHandler_H__ */
Index: /code/branches/network/src/core/TclBind.cc
===================================================================
--- /code/branches/network/src/core/TclBind.cc	(revision 1545)
+++ /code/branches/network/src/core/TclBind.cc	(revision 1545)
@@ -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 <iostream>
+#include <string>
+
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "Debug.h"
+#include "TclThreadManager.h"
+#include "TclBind.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutGeneric(tcl, createConsoleCommand(createFunctor(&TclBind::tcl), "tcl"));
+    SetConsoleCommandShortcutGeneric(bgerror, createConsoleCommand(createFunctor(&TclBind::bgerror), "bgerror"));
+
+    TclBind::TclBind()
+    {
+        this->interpreter_ = 0;
+        this->bSetTclLibPath_ = false;
+    }
+
+    TclBind::~TclBind()
+    {
+        if (this->interpreter_)
+            delete this->interpreter_;
+    }
+
+    TclBind& TclBind::getInstance()
+    {
+        static TclBind instance;
+        return instance;
+    }
+
+    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().toString();
+
+        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/network/src/core/TclBind.h
===================================================================
--- /code/branches/network/src/core/TclBind.h	(revision 1545)
+++ /code/branches/network/src/core/TclBind.h	(revision 1545)
@@ -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 _TclBind_H__
+#define _TclBind_H__
+
+#include "CorePrereqs.h"
+
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport TclBind
+    {
+        public:
+            static TclBind& getInstance();
+
+            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();
+            TclBind(const TclBind& other);
+            ~TclBind();
+
+            Tcl::interpreter* interpreter_;
+            std::string tclLibPath_;
+            bool bSetTclLibPath_;
+    };
+}
+
+#endif /* _TclBind_H__ */
Index: /code/branches/network/src/core/TclThreadManager.cc
===================================================================
--- /code/branches/network/src/core/TclThreadManager.cc	(revision 1545)
+++ /code/branches/network/src/core/TclThreadManager.cc	(revision 1545)
@@ -0,0 +1,668 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <string>
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include <OgreTimer.h>
+
+#include "CoreIncludes.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "Debug.h"
+#include "TclBind.h"
+#include "TclThreadManager.h"
+#include "util/Convert.h"
+
+#define TCLTHREADMANAGER_MAX_QUEUE_LENGTH 100
+#define TCLTHREADMANAGER_MAX_CPU_USAGE 0.50
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutGeneric(tclexecute, createConsoleCommand(createFunctor(&TclThreadManager::execute), "tclexecute")).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommandShortcutGeneric(tclquery,   createConsoleCommand(createFunctor(&TclThreadManager::query),   "tclquery"  )).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, create,  false);
+    SetConsoleCommand(TclThreadManager, destroy, false).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, execute, false).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, query,   false).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, status,  false);
+    SetConsoleCommand(TclThreadManager, dump,    false).setArgumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, flush,   false).setArgumentCompleter(0, autocompletion::tclthreads());
+
+    TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance();
+
+    TclThreadManager::TclThreadManager()
+    {
+        RegisterRootObject(TclThreadManager);
+
+        this->threadCounter_ = 0;
+        this->orxonoxInterpreterBundle_.id_ = 0;
+        this->orxonoxInterpreterBundle_.interpreter_ = TclBind::getInstance().getTclInterpreter();
+#if (BOOST_VERSION >= 103500)
+        this->threadID_ = boost::this_thread::get_id();
+#else
+        //
+#endif
+    }
+
+    TclThreadManager& TclThreadManager::getInstance()
+    {
+        static TclThreadManager instance;
+        return instance;
+    }
+
+    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().toString();
+            }
+
+            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/network/src/core/TclThreadManager.h
===================================================================
--- /code/branches/network/src/core/TclThreadManager.h	(revision 1545)
+++ /code/branches/network/src/core/TclThreadManager.h	(revision 1545)
@@ -0,0 +1,135 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+{
+    class boost::thread;
+
+    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
+    {
+        public:
+            static TclThreadManager& getInstance();
+
+            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);
+
+            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 error(const std::string& error);
+            void debug(const std::string& error);
+
+            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);
+
+            virtual void tick(float dt);
+
+            std::list<unsigned int> getThreadList() const;
+
+        private:
+            TclThreadManager();
+            TclThreadManager(const TclThreadManager& other);
+            ~TclThreadManager() {}
+
+            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
+    };
+
+    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
+}
+
+#endif /* _TclThreadManager_H__ */
Index: /code/branches/network/src/core/XMLPort.cc
===================================================================
--- /code/branches/network/src/core/XMLPort.cc	(revision 1545)
+++ /code/branches/network/src/core/XMLPort.cc	(revision 1545)
@@ -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/network/src/core/XMLPort.h
===================================================================
--- /code/branches/network/src/core/XMLPort.h	(revision 1545)
+++ /code/branches/network/src/core/XMLPort.h	(revision 1545)
@@ -0,0 +1,358 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/XMLIncludes.h"
+#include "util/MultiTypeMath.h"
+#include "tinyxml/ticpp.h"
+#include "Executor.h"
+#include "Debug.h"
+#include "CoreIncludes.h"
+#include "BaseObject.h"
+
+
+#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), #savefunction), xmlelement, mode)
+#define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode)
+
+#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
+#define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
+
+#define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
+    orxonox::XMLPortClassParamContainer<classname>* containername = (orxonox::XMLPortClassParamContainer<classname>*)(this->getIdentifier()->getXMLPortParamContainer(paramname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassParamContainer<classname>(std::string(paramname), loadexecutor, saveexecutor); \
+        this->getIdentifier()->addXMLPortParamContainer(paramname, containername); \
+    } \
+    containername->port(this, 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), #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+#define XMLPortObject_Template(classname, objectclass, sectionname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction), #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>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \
+        this->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 MultiTypeMath& param) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) = 0;
+
+        protected:
+            std::string paramname_;
+            ParseResult parseResult_;
+
+    };
+
+    template <class T>
+    class XMLPortClassParamContainer : public XMLPortParamContainer
+    {
+        struct ParseParams
+        {
+            T* object;
+            Element* xmlelement;
+            XMLPort::Mode mode;
+        };
+
+        public:
+            XMLPortClassParamContainer(const std::string paramname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+            {
+                this->paramname_ = paramname;
+                this->loadexecutor_ = loadexecutor;
+                this->saveexecutor_ = saveexecutor;
+            }
+
+            XMLPortParamContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
+            {
+                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) << ((BaseObject*)object)->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")." << std::endl << ((BaseObject*)object)->getLoaderIndentation();
+                            if (this->loadexecutor_->parse(object, attribute, ","))
+                                this->parseResult_ = PR_finished;
+                            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 '" << object->getIdentifier()->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << ((BaseObject*)object)->getLevelfile() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                    if (this->saveexecutor_)
+                    {
+//                        xmlelement.SetAttribute(this->paramname_, "...");
+                    }
+                }
+
+                return (*this);
+            }
+
+            XMLPortParamContainer& port(const ParseParams& parseParams)
+            {
+                return this->port(parseParams.object, *parseParams.xmlelement, parseParams.mode);
+            }
+
+            XMLPortParamContainer& portIfWaitingForDefaultValues(const ParseResult& result, const ParseParams& params)
+            {
+                if (result == PR_waiting_for_default_values)
+                    return this->port(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 MultiTypeMath& param)
+            {
+                if (!this->loadexecutor_->defaultValueSet(index))
+                    this->loadexecutor_->setDefaultValue(index, param);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1)
+            {
+                if (!this->loadexecutor_->defaultValueSet(0))
+                    this->loadexecutor_->setDefaultValues(param1);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& 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 MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& 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_;
+    };
+
+    template <class T, class O>
+    class XMLPortClassObjectContainer : public XMLPortObjectContainer
+    {
+        public:
+            XMLPortClassObjectContainer(const std::string sectionname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
+            {
+                this->sectionname_ = sectionname;
+                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 = ID(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 " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+                                            }
+                                            else
+                                            {
+                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << object->getIdentifier()->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 '" << object->getIdentifier()->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/network/src/core/input/Button.cc
===================================================================
--- /code/branches/network/src/core/input/Button.cc	(revision 1545)
+++ /code/branches/network/src/core/input/Button.cc	(revision 1545)
@@ -0,0 +1,215 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/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');
+
+        unsigned int iToken = 0;
+
+        // for real axes, we can feed a ButtonThreshold argument as entire command
+        if (getLowercase(tokens[0]) == "buttonthreshold")
+        {
+          if (tokens.size() == 1)
+            continue;
+          // may fail, but doesn't matter
+          convertValue(&buttonThreshold_, tokens[1]);
+          continue;
+        }
+
+        // first argument can be OnPress, OnHold OnRelease or nothing
+        KeybindMode::Enum mode = KeybindMode::None;
+        if (getLowercase(tokens[iToken]) == "onpress")
+          mode = KeybindMode::OnPress,   iToken++;
+        if (getLowercase(tokens[iToken]) == "onrelease")
+          mode = KeybindMode::OnRelease, iToken++;
+        if (getLowercase(tokens[iToken]) == "onhold")
+          mode = KeybindMode::OnHold,    iToken++;
+
+        if (iToken == tokens.size())
+          continue;
+
+        // second argument can be the amplitude for the case it as an axis command
+        // default amplitude is 1.0f
+        float paramModifier = 1.0f;
+        if (getLowercase(tokens[iToken]) == "scale")
+        {
+          iToken++;
+          if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
+          {
+            COUT(2) << "Error while parsing key binding " << name_
+                << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
+            if (iToken == tokens.size())
+              continue;
+          }
+          iToken++;
+        }
+
+        // no more arguments expected except for the actual command
+        if (iToken == tokens.size())
+          continue;
+
+        std::string commandStr;
+        while (iToken != tokens.size())
+          commandStr += tokens[iToken++] + " ";
+
+        // evaluate the command
+        CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
+        if (!eval.isValid())
+          continue;
+
+        // check for param command
+        int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
+        if (paramIndex >= 0)
+        {
+          // parameter supported command
+          ParamCommand* cmd = new ParamCommand();
+          cmd->paramModifier_ = paramModifier;
+          cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
+
+          // add command to the buffer if not yet existing
+          for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
+          {
+            if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())
+                == getLowercase(commandStr))
+            {
+              // already in list
+              cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
+              break;
+            }
+          }
+          if (cmd->paramCommand_ == 0)
+          {
+            cmd->paramCommand_ = new BufferedParamCommand();
+            paramCommandBuffer.push_back(cmd->paramCommand_);
+            cmd->paramCommand_->evaluation_ = eval;
+            cmd->paramCommand_->paramIndex_ = paramIndex;
+          }
+
+
+          // we don't know whether this is an actual axis or just a button
+          if (mode == KeybindMode::None)
+          {
+            if (!addParamCommand(cmd))
+            {
+              mode = eval.getConsoleCommand()->getKeybindMode();
+              commands[mode].push_back(cmd);
+            }
+          }
+        }
+        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;
+  }
+}
Index: /code/branches/network/src/core/input/Button.h
===================================================================
--- /code/branches/network/src/core/input/Button.h	(revision 1545)
+++ /code/branches/network/src/core/input/Button.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+ @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_;
+  };
+}
+
+#endif /* _Button_H__ */
Index: /code/branches/network/src/core/input/CalibratorCallback.cc
===================================================================
--- /code/branches/network/src/core/input/CalibratorCallback.cc	(revision 1545)
+++ /code/branches/network/src/core/input/CalibratorCallback.cc	(revision 1545)
@@ -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:
+ *      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/network/src/core/input/CalibratorCallback.h
===================================================================
--- /code/branches/network/src/core/input/CalibratorCallback.h	(revision 1545)
+++ /code/branches/network/src/core/input/CalibratorCallback.h	(revision 1545)
@@ -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, const HandlerState &state) { }
+  };
+}
+
+#endif /* _CalibratorCallback_H__ */
Index: /code/branches/network/src/core/input/HalfAxis.cc
===================================================================
--- /code/branches/network/src/core/input/HalfAxis.cc	(revision 1545)
+++ /code/branches/network/src/core/input/HalfAxis.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+ @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/network/src/core/input/HalfAxis.h
===================================================================
--- /code/branches/network/src/core/input/HalfAxis.h	(revision 1545)
+++ /code/branches/network/src/core/input/HalfAxis.h	(revision 1545)
@@ -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:
+ *      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/network/src/core/input/InputBuffer.cc
===================================================================
--- /code/branches/network/src/core/input/InputBuffer.cc	(revision 1545)
+++ /code/branches/network/src/core/input/InputBuffer.cc	(revision 1545)
@@ -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, const HandlerState& state)
+    {
+        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/network/src/core/input/InputBuffer.h
===================================================================
--- /code/branches/network/src/core/input/InputBuffer.h	(revision 1545)
+++ /code/branches/network/src/core/input/InputBuffer.h	(revision 1545)
@@ -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:
+ *      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, const HandlerState& state);
+
+            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/network/src/core/input/InputCommands.cc
===================================================================
--- /code/branches/network/src/core/input/InputCommands.cc	(revision 1545)
+++ /code/branches/network/src/core/input/InputCommands.cc	(revision 1545)
@@ -0,0 +1,127 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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   ###
+  // ###############################
+
+  /**
+  * 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    #####
+  // ###############################
+
+  /**
+  * 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     #####
+  // ###############################
+
+  /**
+  * 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/network/src/core/input/InputCommands.h
===================================================================
--- /code/branches/network/src/core/input/InputCommands.h	(revision 1545)
+++ /code/branches/network/src/core/input/InputCommands.h	(revision 1545)
@@ -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 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/network/src/core/input/InputInterfaces.h
===================================================================
--- /code/branches/network/src/core/input/InputInterfaces.h	(revision 1545)
+++ /code/branches/network/src/core/input/InputInterfaces.h	(revision 1545)
@@ -0,0 +1,322 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/OIS.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+  namespace KeyCode
+  {
+    // note: KeyCode comments were directly taken from OISKeyboard.h
+    enum Enum
+    {
+      Unassigned    = OIS::KC_UNASSIGNED,  
+      Escape        = OIS::KC_ESCAPE,      
+      NumRow1       = OIS::KC_1,           
+      NumRow2       = OIS::KC_2,           
+      NumRow3       = OIS::KC_3,           
+      NumRow4       = OIS::KC_4,           
+      NumRow5       = OIS::KC_5,           
+      NumRow6       = OIS::KC_6,           
+      NumRow7       = OIS::KC_7,           
+      NumRow8       = OIS::KC_8,           
+      NumRow9       = OIS::KC_9,           
+      NumRow0       = OIS::KC_0,           
+      Minus         = OIS::KC_MINUS,           // - on main keyboard
+      Equals        = OIS::KC_EQUALS,      
+      Back          = OIS::KC_BACK,            // backspace
+      Tab           = OIS::KC_TAB,         
+      Q             = OIS::KC_Q,           
+      W             = OIS::KC_W,           
+      E             = OIS::KC_E,           
+      R             = OIS::KC_R,           
+      T             = OIS::KC_T,           
+      Y             = OIS::KC_Y,           
+      U             = OIS::KC_U,           
+      I             = OIS::KC_I,           
+      O             = OIS::KC_O,           
+      P             = OIS::KC_P,           
+      LeftBracket   = OIS::KC_LBRACKET,    
+      RightBracket  = OIS::KC_RBRACKET,    
+      Return        = OIS::KC_RETURN,          // Enter on main keyboard
+      LeftControl   = OIS::KC_LCONTROL,    
+      A             = OIS::KC_A,           
+      S             = OIS::KC_S,           
+      D             = OIS::KC_D,           
+      F             = OIS::KC_F,           
+      G             = OIS::KC_G,           
+      H             = OIS::KC_H,           
+      J             = OIS::KC_J,           
+      K             = OIS::KC_K,           
+      L             = OIS::KC_L,           
+      Semicolon     = OIS::KC_SEMICOLON,   
+      Apostrophe    = OIS::KC_APOSTROPHE,  
+      Grave         = OIS::KC_GRAVE,           // accent
+      LeftShift     = OIS::KC_LSHIFT,      
+      Backslash     = OIS::KC_BACKSLASH,   
+      Z             = OIS::KC_Z,           
+      X             = OIS::KC_X,           
+      C             = OIS::KC_C,           
+      V             = OIS::KC_V,           
+      B             = OIS::KC_B,           
+      N             = OIS::KC_N,           
+      M             = OIS::KC_M,           
+      Comma         = OIS::KC_COMMA,       
+      Period        = OIS::KC_PERIOD,          // . on main keyboard
+      Slash         = OIS::KC_SLASH,           // / on main keyboard
+      RightShift    = OIS::KC_RSHIFT,      
+      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
+      LeftAlt       = OIS::KC_LMENU,           // left Alt
+      Space         = OIS::KC_SPACE,       
+      CapsLock      = OIS::KC_CAPITAL,     
+      F1            = OIS::KC_F1,          
+      F2            = OIS::KC_F2,          
+      F3            = OIS::KC_F3,          
+      F4            = OIS::KC_F4,          
+      F5            = OIS::KC_F5,          
+      F6            = OIS::KC_F6,          
+      F7            = OIS::KC_F7,          
+      F8            = OIS::KC_F8,          
+      F9            = OIS::KC_F9,          
+      F10           = OIS::KC_F10,         
+      Numlock       = OIS::KC_NUMLOCK,     
+      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
+      Numpad7       = OIS::KC_NUMPAD7,     
+      Numpad8       = OIS::KC_NUMPAD8,     
+      Numpad9       = OIS::KC_NUMPAD9,     
+      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
+      Numpad4       = OIS::KC_NUMPAD4,     
+      Numpad5       = OIS::KC_NUMPAD5,     
+      Numpad6       = OIS::KC_NUMPAD6,     
+      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
+      Numpad1       = OIS::KC_NUMPAD1,     
+      Numpad2       = OIS::KC_NUMPAD2,     
+      Numpad3       = OIS::KC_NUMPAD3,     
+      Numpad0       = OIS::KC_NUMPAD0,     
+      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
+      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
+      F11           = OIS::KC_F11,         
+      F12           = OIS::KC_F12,         
+      F13           = OIS::KC_F13,             //                     (NEC PC98)
+      F14           = OIS::KC_F14,             //                     (NEC PC98)
+      F15           = OIS::KC_F15,             //                     (NEC PC98)
+      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
+      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
+      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
+      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
+      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
+      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
+      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
+      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+      AT            = OIS::KC_AT,              //                     (NEC PC98)
+      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
+      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
+      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
+      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
+      AX            = OIS::KC_AX,              //                     (Japan AX)
+      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
+      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
+      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
+      RightControl  = OIS::KC_RCONTROL,    
+      Mute          = OIS::KC_MUTE,            // Mute
+      Calculator    = OIS::KC_CALCULATOR,      // Calculator
+      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
+      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
+      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
+      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
+      WebHome       = OIS::KC_WEBHOME,         // Web home
+      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
+      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
+      SYSRQ         = OIS::KC_SYSRQ,       
+      RightAlt      = OIS::KC_RMENU,           // right Alt
+      Pause         = OIS::KC_PAUSE,           // Pause
+      Home          = OIS::KC_HOME,            // Home on arrow keypad
+      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
+      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
+      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
+      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
+      End           = OIS::KC_END,             // End on arrow keypad
+      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
+      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
+      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
+      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
+      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
+      RightWindows  = OIS::KC_RWIN,            // Right Windows key
+      Apps          = OIS::KC_APPS,            // AppMenu key
+      Power         = OIS::KC_POWER,           // System Power
+      Sleep         = OIS::KC_SLEEP,           // System Sleep
+      Wake          = OIS::KC_WAKE,            // System Wake
+      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
+      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
+      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
+      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
+      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
+      WebBack       = OIS::KC_WEBBACK,         // Web Back
+      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
+      Mail          = OIS::KC_MAIL,            // Mail
+      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
+    };
+  }
+
+  namespace MouseButton
+  {
+    enum Enum
+    {
+      Left    = OIS::MB_Left,
+      Right   = OIS::MB_Right,
+      Middle  = OIS::MB_Middle,
+      Button3 = OIS::MB_Button3,
+      Button4 = OIS::MB_Button4,
+      Button5 = OIS::MB_Button5,
+      Button6 = OIS::MB_Button6,
+      Button7 = OIS::MB_Button7
+    };
+  }
+
+  namespace KeyboardModifier
+  {
+    enum Enum
+    {
+      Shift = 0x0000001,
+      Ctrl  = 0x0000010,
+      Alt   = 0x0000100
+    };
+  }
+
+  struct _CoreExport Key
+  {
+    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
+    KeyCode::Enum key;
+    unsigned int text;
+  };
+
+  class _CoreExport KeyEvent
+  {
+  public:
+    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
+    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
+    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
+    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
+
+    const KeyCode::Enum key;
+    unsigned int text;
+    unsigned int modifiers;
+  };
+
+  //typedef OIS::MouseState MouseState;
+
+  /*class _CoreExport JoyStickState
+  {
+  public:
+    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
+    JoyStickState() { clear(); }
+    int mJoyStickID;
+		JoyStickState() { clear(); }
+
+		std::vector<bool> mButtons;
+		int axes[16];
+		std::vector<Vector3> mVectors;
+  };*/
+  
+  /**
+  * Helper struct to determine which handlers of an object (can implement
+  * multiple handlers) are active.
+  */
+  struct HandlerState
+  {
+    HandlerState() : key(false), mouse(false), joyStick(false) { }
+    bool key;
+    bool mouse;
+    bool joyStick;
+  };
+
+  class _CoreExport InputTickable
+  {
+  public:
+    virtual ~InputTickable() { }
+    virtual void tickInput(float dt, const HandlerState& state) = 0;
+  };
+
+  /**
+    @brief Interface class used for key input listeners.
+  */
+  class _CoreExport KeyHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~KeyHandler() { }
+    virtual void keyPressed (const KeyEvent& evt) = 0;
+    virtual void keyReleased(const KeyEvent& evt) = 0;
+    virtual void keyHeld    (const KeyEvent& evt) = 0;
+    //virtual void tickKey    (float dt) { }
+  };
+
+  /**
+    @brief Interface class used for mouse input listeners.
+  */
+  class _CoreExport MouseHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~MouseHandler() { }
+    virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
+    virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
+    virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
+    virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+    virtual void mouseScrolled      (int abs, int rel)     = 0;
+    //virtual void tickMouse          (float dt) { }
+  };
+
+
+  /**
+    @brief Interface class used for joy stick input listeners.
+  */
+  class _CoreExport JoyStickHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~JoyStickHandler() { }
+    virtual void joyStickButtonPressed (int joyStickID, int button) = 0;
+    virtual void joyStickButtonReleased(int joyStickID, int button) = 0;
+    virtual void joyStickButtonHeld    (int joyStickID, int button) = 0;
+    virtual void joyStickAxisMoved     (int joyStickID, int axis, float value) = 0;
+    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
+    //virtual void tickJoyStick          (float dt) { }
+  };
+
+}
+
+#endif /* _InputInterfaces_H__ */
Index: /code/branches/network/src/core/input/InputManager.cc
===================================================================
--- /code/branches/network/src/core/input/InputManager.cc	(revision 1545)
+++ /code/branches/network/src/core/input/InputManager.cc	(revision 1545)
@@ -0,0 +1,1552 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <limits.h>
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Debug.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/Shell.h"               // hack!
+#include "InputBuffer.h"
+#include "KeyBinder.h"
+#include "KeyDetector.h"
+#include "CalibratorCallback.h"
+
+namespace orxonox
+{
+  SetConsoleCommandShortcut(InputManager, keyBind);
+  SetConsoleCommandShortcut(InputManager, storeKeyStroke);
+  SetConsoleCommandShortcut(InputManager, calibrate);
+
+  // ###############################
+  // ###    Internal Methods     ###
+  // ###############################
+  // ###############################
+
+  /**
+    @brief Constructor only sets member fields to initial zero values
+           and registers the class in the class hierarchy.
+  */
+  InputManager::InputManager() :
+      inputSystem_(0), keyboard_(0), mouse_(0),
+      joySticksSize_(0),
+      keyBinder_(0), keyDetector_(0), buffer_(0), calibratorCallback_(0),
+      state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT),
+      keyboardModifiers_(0)
+  {
+    RegisterRootObject(InputManager);
+  }
+
+  /**
+    @brief The one instance of the InputManager is stored in this function.
+    @return A reference to the only instance of the InputManager
+  */
+  InputManager& InputManager::_getSingleton()
+  {
+    static InputManager theOnlyInstance;
+    return theOnlyInstance;
+  }
+
+  /**
+    @brief Destructor only called at the end of the program, after main.
+  */
+  InputManager::~InputManager()
+  {
+    _destroy();
+  }
+
+  /**
+    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
+           the joysticks and assigns the key bindings.
+    @param windowHnd The window handle of the render window
+    @param windowWidth The width of the render window
+    @param windowHeight The height of the render window
+  */
+  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+        bool createKeyboard, bool createMouse, bool createJoySticks)
+  {
+    if (state_ == IS_UNINIT)
+    {
+      CCOUT(3) << "Initialising Input System..." << std::endl;
+      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
+
+      OIS::ParamList paramList;
+      std::ostringstream windowHndStr;
+
+      // Fill parameter list
+      windowHndStr << (unsigned int)windowHnd;
+      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
+      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+//#if defined OIS_LINUX_PLATFORM
+//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+//#endif
+
+      try
+      {
+        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+      }
+      catch (OIS::Exception ex)
+      {
+        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
+            << "OIS message: \"" << ex.eText << "\"" << std::endl;
+        inputSystem_ = 0;
+        return false;
+      }
+
+      if (createKeyboard)
+        _initialiseKeyboard();
+
+      if (createMouse)
+        _initialiseMouse();
+
+      if (createJoySticks)
+        _initialiseJoySticks();
+
+      // Set mouse/joystick region
+      if (mouse_)
+      {
+        setWindowExtents(windowWidth, windowHeight);
+      }
+
+      state_ = IS_NONE;
+      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+
+      // InputManager holds the input buffer --> create one and add it.
+      buffer_ = new InputBuffer();
+      addKeyHandler(buffer_, "buffer");
+      Shell::getInstance().setInputBuffer(buffer_);
+
+      keyBinder_ = new KeyBinder();
+      keyBinder_->loadBindings();
+      addKeyHandler(keyBinder_, "keybinder");
+      addMouseHandler(keyBinder_, "keybinder");
+      addJoyStickHandler(keyBinder_, "keybinder");
+
+      keyDetector_ = new KeyDetector();
+      keyDetector_->loadBindings();
+      addKeyHandler(keyDetector_, "keydetector");
+      addMouseHandler(keyDetector_, "keydetector");
+      addJoyStickHandler(keyDetector_, "keydetector");
+
+      calibratorCallback_ = new CalibratorCallback();
+      addKeyHandler(calibratorCallback_, "calibratorcallback");
+
+      setConfigValues();
+
+      CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+    }
+    return true;
+  }
+
+  /**
+    @brief Creates a keyboard and sets the event handler.
+    @return False if keyboard stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseKeyboard()
+  {
+    if (keyboard_ != 0)
+    {
+      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+      {
+        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
+        // register our listener in OIS.
+        keyboard_->setEventCallback(this);
+        // note: OIS will not detect keys that have already been down when the keyboard was created.
+        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
+        return false;
+      }
+    }
+    catch (OIS::Exception ex)
+    {
+      // TODO: Test this output regarding formatting
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      keyboard_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates a mouse and sets the event handler.
+    @return False if mouse stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseMouse()
+  {
+    if (mouse_ != 0)
+    {
+      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+      {
+        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+        // register our listener in OIS.
+        mouse_->setEventCallback(this);
+        CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+        return false;
+      }
+    }
+    catch (OIS::Exception ex)
+    {
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      mouse_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates all joy sticks and sets the event handler.
+    @return False joy stick stay uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseJoySticks()
+  {
+    if (joySticksSize_ > 0)
+    {
+      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
+      return true;
+    }
+    bool success = false;
+    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
+    {
+      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+      {
+        try
+        {
+          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
+          joySticks_.push_back(stig);
+          // register our listener in OIS.
+          stig->setEventCallback(this);
+          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
+          success = true;
+        }
+        catch (OIS::Exception ex)
+        {
+          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
+              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+        }
+      }
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
+      return false;
+    }
+    joySticksSize_ = joySticks_.size();
+    activeJoyStickHandlers_.resize(joySticksSize_);
+    joyStickButtonsDown_.resize(joySticksSize_);
+    povStates_.resize(joySticksSize_);
+    sliderStates_.resize(joySticksSize_);
+    joySticksCalibration_.resize(joySticksSize_);
+    for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
+    {
+      // reset the calibration with default values
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
+        joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
+        joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
+      }
+    }
+    return success;
+  }
+
+  /**
+    @brief Sets the configurable values. Use keybindings.ini as file..
+  */
+  void InputManager::setConfigValues()
+  {
+    if (joySticksSize_)
+    {
+      std::vector<MultiTypeMath> coeffPos;
+      std::vector<MultiTypeMath> coeffNeg;
+      std::vector<MultiTypeMath> zero;
+      coeffPos.resize(24);
+      coeffNeg.resize(24);
+      zero.resize(24);
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        coeffPos[i] =  1.0f/32767.0f;
+        coeffNeg[i] =  1.0f/32768.0f;
+        zero[i]     =  0;
+      }
+
+      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffPos", coeffPos);
+          getIdentifier()->addConfigValueContainer("CoeffPos", cont);
+      }
+      cont->getValue(&coeffPos);
+
+      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffNeg", coeffNeg);
+          getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
+      }
+      cont->getValue(&coeffNeg);
+
+      cont = getIdentifier()->getConfigValueContainer("Zero");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "Zero", zero);
+          getIdentifier()->addConfigValueContainer("Zero", cont);
+      }
+      cont->getValue(&zero);
+
+      // copy values to our own variables
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
+        joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
+        joySticksCalibration_[0].zeroStates[i]    = zero[i];
+      }
+    }
+  }
+
+  /**
+    @brief Destroys all the created input devices and sets the InputManager to construction state.
+  */
+  void InputManager::_destroy()
+  {
+    if (state_ != IS_UNINIT)
+    {
+      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
+
+      if (buffer_)
+        delete buffer_;
+
+      if (keyBinder_)
+        delete keyBinder_;
+
+      if (keyDetector_)
+        delete keyDetector_;
+
+      if (calibratorCallback_)
+        delete calibratorCallback_;
+
+      keyHandlers_.clear();
+      mouseHandlers_.clear();
+      joyStickHandlers_.clear();
+
+      _destroyKeyboard();
+      _destroyMouse();
+      _destroyJoySticks();
+
+      activeHandlers_.clear();
+
+      // inputSystem_ can never be 0, or else the code is mistaken
+      OIS::InputManager::destroyInputSystem(inputSystem_);
+      inputSystem_ = 0;
+
+      state_ = IS_UNINIT;
+      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
+    }
+  }
+
+  /**
+    @brief Destroys the keyboard and sets it to 0.
+  */
+  void InputManager::_destroyKeyboard()
+  {
+    if (keyboard_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(keyboard_);
+    keyboard_ = 0;
+    activeKeyHandlers_.clear();
+    keysDown_.clear();
+    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys the mouse and sets it to 0.
+  */
+  void InputManager::_destroyMouse()
+  {
+    if (mouse_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(mouse_);
+    mouse_ = 0;
+    activeMouseHandlers_.clear();
+    mouseButtonsDown_.clear();
+    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys all the joy sticks and resizes the lists to 0.
+  */
+  void InputManager::_destroyJoySticks()
+  {
+    if (joySticksSize_ > 0)
+    {
+      // note: inputSystem_ can never be 0, or else the code is mistaken
+      for (unsigned int i = 0; i < joySticksSize_; i++)
+        if (joySticks_[i] != 0)
+          inputSystem_->destroyInputObject(joySticks_[i]);
+
+      joySticks_.clear();
+      joySticksSize_ = 0;
+      activeJoyStickHandlers_.clear();
+      joyStickButtonsDown_.clear();
+      povStates_.clear();
+      sliderStates_.clear();
+      joySticksCalibration_.clear();
+    }
+    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
+  }
+
+  void InputManager::_saveState()
+  {
+    savedHandlers_.activeHandlers_ = activeHandlers_;
+    savedHandlers_.activeJoyStickHandlers_ = activeJoyStickHandlers_;
+    savedHandlers_.activeKeyHandlers_ = activeKeyHandlers_;
+    savedHandlers_.activeMouseHandlers_ = activeMouseHandlers_;
+  }
+
+  void InputManager::_restoreState()
+  {
+    activeHandlers_ = savedHandlers_.activeHandlers_;
+    activeJoyStickHandlers_ = savedHandlers_.activeJoyStickHandlers_;
+    activeKeyHandlers_ = savedHandlers_.activeKeyHandlers_;
+    activeMouseHandlers_ = savedHandlers_.activeMouseHandlers_;
+  }
+
+  void InputManager::_updateTickables()
+  {
+    // we can use a map to have a list of unique pointers (an object can implement all 3 handlers)
+    std::map<InputTickable*, HandlerState> tempSet;
+    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
+      tempSet[activeKeyHandlers_[iHandler]].joyStick = true;
+    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
+      tempSet[activeMouseHandlers_[iHandler]].mouse = true;
+    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+        tempSet[activeJoyStickHandlers_[iJoyStick][iHandler]].joyStick = true;
+
+    // copy the content of the map back to the actual vector
+    activeHandlers_.clear();
+    for (std::map<InputTickable*, HandlerState>::const_iterator itHandler = tempSet.begin();
+        itHandler != tempSet.end(); itHandler++)
+      activeHandlers_.push_back(std::pair<InputTickable*, HandlerState>((*itHandler).first, (*itHandler).second));
+  }
+
+
+  // #################################
+  // ### Private Interface Methods ###
+  // #################################
+  // #################################
+
+  /**
+    @brief Updates the InputManager. Tick is called by Orxonox.
+    @param dt Delta time
+  */
+  void InputManager::_tick(float dt)
+  {
+    if (state_ == IS_UNINIT)
+      return;
+
+    if (state_ != stateRequest_)
+    {
+      InputState sr = stateRequest_;
+      switch (sr)
+      {
+      case IS_NORMAL:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        // normal play mode
+        // note: we assume that the handlers exist since otherwise, something's wrong anyway.
+        enableKeyHandler("keybinder");
+        enableMouseHandler("keybinder");
+        enableJoyStickHandler("keybinder", 0);
+        stateRequest_ = IS_NORMAL;
+        state_ = IS_NORMAL;
+        break;
+
+      case IS_GUI:
+        state_ = IS_GUI;
+        break;
+
+      case IS_CONSOLE:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        enableMouseHandler("keybinder");
+        enableJoyStickHandler("keybinder", 0);
+        enableKeyHandler("buffer");
+        stateRequest_ = IS_CONSOLE;
+        state_ = IS_CONSOLE;
+        break;
+
+      case IS_DETECT:
+        savedState_ = state_;
+        _saveState();
+
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        enableKeyHandler("keydetector");
+        enableMouseHandler("keydetector");
+        enableJoyStickHandler("keydetector", 0);
+
+        stateRequest_ = IS_DETECT;
+        state_ = IS_DETECT;
+        break;
+
+      case IS_NODETECT:
+        _restoreState();
+        keysDown_.clear();
+        mouseButtonsDown_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          joyStickButtonsDown_[i].clear();
+        state_ = IS_NODETECT;
+        stateRequest_ = savedState_;
+        break;
+
+      case IS_CALIBRATE:
+        if (joySticksSize_)
+        {
+          savedState_ = _getSingleton().state_;
+          for (unsigned int i = 0; i < 24; i++)
+          {
+            marginalsMax_[i] = INT_MIN;
+            marginalsMin_[i] = INT_MAX;
+          }
+          COUT(0) << "Move all joy stick axes in all directions a few times. "
+            << "Then put all axes in zero state and hit enter." << std::endl;
+
+          savedState_ = state_;
+          _saveState();
+
+          activeKeyHandlers_.clear();
+          activeMouseHandlers_.clear();
+          for (unsigned int i = 0; i < joySticksSize_; i++)
+            activeJoyStickHandlers_[i].clear();
+
+          enableKeyHandler("calibratorcallback");
+          stateRequest_ = IS_CALIBRATE;
+          state_ = IS_CALIBRATE;
+        }
+        else
+        {
+          COUT(3) << "Connot calibrate, no joy stick found!" << std::endl;
+          stateRequest_ = state_;
+        }
+        break;
+
+      case IS_NOCALIBRATE:
+        _completeCalibration();
+        _restoreState();
+        keyBinder_->resetJoyStickAxes();
+        state_ = IS_NOCALIBRATE;
+        stateRequest_ = savedState_;
+        break;
+
+      case IS_NONE:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+        state_ = IS_NONE;
+
+      default:
+        break;
+      }
+    }
+
+    // Capture all the input. This calls the event handlers in InputManager.
+    if (mouse_)
+      mouse_->capture();
+    if (keyboard_)
+      keyboard_->capture();
+    for (unsigned  int i = 0; i < joySticksSize_; i++)
+      joySticks_[i]->capture();
+
+    if (state_ != IS_CALIBRATE)
+    {
+      // call all the handlers for the held key events
+      for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+        for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
+          activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
+
+      // call all the handlers for the held mouse button events
+      for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+        for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
+          activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
+
+      // call all the handlers for the held joy stick button events
+      for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+        for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
+          for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+            activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+    }
+
+    // call the ticks for the handlers (need to be treated specially)
+    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
+      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
+  }
+    
+  void InputManager::_completeCalibration()
+  {
+    for (unsigned int i = 0; i < 24; i++)
+    {
+      // positive coefficient
+      if (marginalsMax_[i] == INT_MIN)
+        marginalsMax_[i] =  32767;
+      // coefficients
+      if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
+        joySticksCalibration_[0].positiveCoeff[i] =  1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
+      else
+        joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
+
+      // config value
+      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
+
+      // negative coefficient
+      if (marginalsMin_[i] == INT_MAX)
+        marginalsMin_[i] = -32768;
+      // coefficients
+      if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
+        joySticksCalibration_[0].negativeCoeff[i] = -1.0f/(marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
+      else
+        joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
+      // config value
+      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
+
+      // zero states
+      if (i < 8)
+      {
+        if (!(i & 1))
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
+        else
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
+      }
+      else
+      {
+        if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
+        else
+          joySticksCalibration_[0].zeroStates[i] = 0;
+      }
+      // config value
+      cont = getIdentifier()->getConfigValueContainer("Zero");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].zeroStates[i]);
+    }
+  }
+
+  // ###### Key Events ######
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputManager::keyPressed(const OIS::KeyEvent &e)
+  {
+    // check whether the key already is in the list (can happen when focus was lost)
+    unsigned int iKey = 0;
+    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
+      iKey++;
+    if (iKey == keysDown_.size())
+      keysDown_.push_back(Key(e));
+
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputManager::keyReleased(const OIS::KeyEvent &e)
+  {
+    // remove the key from the keysDown_ list
+    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+    {
+      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
+      {
+        keysDown_.erase(keysDown_.begin() + iKey);
+        break;
+      }
+    }
+
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
+
+    return true;
+  }
+
+
+  // ###### Mouse Events ######
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
+  {
+    // check for actual moved event
+    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
+            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
+    }
+
+    // check for mouse scrolled event
+    if (e.state.Z.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+    }
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // check whether the button already is in the list (can happen when focus was lost)
+    unsigned int iButton = 0;
+    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
+      iButton++;
+    if (iButton == mouseButtonsDown_.size())
+      mouseButtonsDown_.push_back((MouseButton::Enum)id);
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseReleased Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // remove the button from the keysDown_ list
+    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+    {
+      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
+      {
+        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
+        break;
+      }
+    }
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
+
+    return true;
+  }
+
+
+  // ###### Joy Stick Events ######
+
+  inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
+  {
+    // use the device to identify which one called the method
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+    {
+      iJoyStick++;
+      if (iJoyStick == joySticksSize_)
+      {
+        CCOUT(3) << "Unknown joystick fired an event. This means there is a bug somewhere! Aborting." << std::endl;
+        abort();
+      }
+    }
+    return iJoyStick;
+  }
+
+  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // check whether the button already is in the list (can happen when focus was lost)
+    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+    unsigned int iButton = 0;
+    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
+      iButton++;
+    if (iButton == buttonsDown.size())
+      buttonsDown.push_back(button);
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
+
+    return true;
+  }
+
+  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // remove the button from the joyStickButtonsDown_ list
+    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
+    {
+      if (buttonsDown[iButton] == button)
+      {
+        buttonsDown.erase(buttonsDown.begin() + iButton);
+        break;
+      }
+    }
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
+
+    return true;
+  }
+
+  void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
+  {
+    if (state_ == IS_CALIBRATE)
+    {
+      if (value > marginalsMax_[axis])
+        marginalsMax_[axis] = value;
+      if (value < marginalsMin_[axis])
+        marginalsMin_[axis] = value;
+    }
+    else
+    {
+      float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
+      if (fValue > 0.0f)
+        fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
+      else
+        fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
+
+      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis, fValue);
+    }
+  }
+
+  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+  {
+    //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000)
+    //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;}
+
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // keep in mind that the first 8 axes are reserved for the sliders
+    _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
+
+    return true;
+  }
+
+  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000)
+    //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;}
+    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
+
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
+      _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
+    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
+      _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
+
+    return true;
+  }
+
+  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // translate the POV into 8 simple buttons
+    int lastState = povStates_[iJoyStick][id];
+    if (lastState & OIS::Pov::North)
+      buttonReleased(arg, 32 + id * 4 + 0);
+    if (lastState & OIS::Pov::South)
+      buttonReleased(arg, 32 + id * 4 + 1);
+    if (lastState & OIS::Pov::East)
+      buttonReleased(arg, 32 + id * 4 + 2);
+    if (lastState & OIS::Pov::West)
+      buttonReleased(arg, 32 + id * 4 + 3);
+
+    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
+
+    int currentState = povStates_[iJoyStick][id];
+    if (currentState & OIS::Pov::North)
+      buttonPressed(arg, 32 + id * 4 + 0);
+    if (currentState & OIS::Pov::South)
+      buttonPressed(arg, 32 + id * 4 + 1);
+    if (currentState & OIS::Pov::East)
+      buttonPressed(arg, 32 + id * 4 + 2);
+    if (currentState & OIS::Pov::West)
+      buttonPressed(arg, 32 + id * 4 + 3);
+
+    return true;
+  }
+
+  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
+
+    return true;
+  }*/
+
+
+  // ################################
+  // ### Static Interface Methods ###
+  // ################################
+  // ################################
+
+  std::string InputManager::bindingCommmandString_s = "";
+
+  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+    bool createKeyboard, bool createMouse, bool createJoySticks)
+  {
+    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
+          createKeyboard, createMouse, createJoySticks);
+  }
+
+  bool InputManager::initialiseKeyboard()
+  {
+    return _getSingleton()._initialiseKeyboard();
+  }
+
+  bool InputManager::initialiseMouse()
+  {
+    return _getSingleton()._initialiseMouse();
+  }
+
+  bool InputManager::initialiseJoySticks()
+  {
+    return _getSingleton()._initialiseJoySticks();
+  }
+
+  int InputManager::numberOfKeyboards()
+  {
+    if (_getSingleton().keyboard_ != 0)
+      return 1;
+    else
+      return 0;
+  }
+
+  int InputManager::numberOfMice()
+  {
+    if (_getSingleton().mouse_ != 0)
+      return 1;
+    else
+      return 0;
+  }
+
+  int InputManager::numberOfJoySticks()
+  {
+    return _getSingleton().joySticksSize_;
+  }
+
+  /*bool InputManager::isKeyDown(KeyCode::Enum key)
+  {
+    if (_getSingleton().keyboard_)
+      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
+    else
+      return false;
+  }*/
+
+  /*bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
+  {
+    if (_getSingleton().keyboard_)
+      return isModifierDown(modifier);
+    else
+      return false;
+  }*/
+
+  /*const MouseState InputManager::getMouseState()
+  {
+    if (_getSingleton().mouse_)
+      return _getSingleton().mouse_->getMouseState();
+    else
+      return MouseState();
+  }*/
+
+  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
+  {
+    if (ID < _getSingleton().joySticksSize_)
+      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
+    else
+      return JoyStickState();
+  }*/
+
+  void InputManager::destroy()
+  {
+    _getSingleton()._destroy();
+  }
+
+  void InputManager::destroyKeyboard()
+  {
+    return _getSingleton()._destroyKeyboard();
+  }
+
+  void InputManager::destroyMouse()
+  {
+    return _getSingleton()._destroyMouse();
+  }
+
+  void InputManager::destroyJoySticks()
+  {
+    return _getSingleton()._destroyJoySticks();
+  }
+
+
+  /**
+    @brief Adjusts the mouse window metrics.
+    This method has to be called every time the size of the window changes.
+    @param width The new width of the render window
+    @param height the new height of the render window
+  */
+  void InputManager::setWindowExtents(const int width, const int height)
+  {
+    if (_getSingleton().mouse_)
+    {
+      // Set mouse region (if window resizes, we should alter this to reflect as well)
+      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
+      mouseState.width  = width;
+      mouseState.height = height;
+    }
+  }
+
+  /**
+    @brief Sets the input mode to either GUI, inGame or Buffer
+    @param mode The new input mode
+    @remark Only has an affect if the mode actually changes
+  */
+  void InputManager::setInputState(const InputState state)
+  {
+    _getSingleton().stateRequest_ = state;
+  }
+
+  /**
+    @brief Returns the current input handling method
+    @return The current input mode.
+  */
+  InputManager::InputState InputManager::getInputState()
+  {
+    return _getSingleton().state_;
+  }
+
+  void InputManager::storeKeyStroke(const std::string& name)
+  {
+    setInputState(IS_NODETECT);
+    COUT(0) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
+    CommandExecutor::execute("config KeyBinder " + name + " " + bindingCommmandString_s, false);
+  }
+
+  void InputManager::keyBind(const std::string& command)
+  {
+    bindingCommmandString_s = command;
+    setInputState(IS_DETECT);
+    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+  }
+
+  void InputManager::calibrate()
+  {
+    _getSingleton().setInputState(IS_CALIBRATE);
+  }
+
+  void InputManager::tick(float dt)
+  {
+    _getSingleton()._tick(dt);
+  }
+
+  // ###### KeyHandler ######
+
+  /**
+    @brief Adds a new key handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Key handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeKeyHandler(const std::string &name)
+  {
+    disableKeyHandler(name);
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  KeyHandler* InputManager::getKeyHandler(const std::string& name)
+  {
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific key handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableKeyHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific key handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableKeyHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeKeyHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a key handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isKeyHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### MouseHandler ######
+  /**
+    @brief Adds a new mouse handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Mouse handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeMouseHandler(const std::string &name)
+  {
+    disableMouseHandler(name);
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  MouseHandler* InputManager::getMouseHandler(const std::string& name)
+  {
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific mouse handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableMouseHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific mouse handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableMouseHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeMouseHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a mouse handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isMouseHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### JoyStickHandler ######
+
+  /**
+    @brief Adds a new joy stick handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a JoyStick handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeJoyStickHandler(const std::string &name)
+  {
+    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
+          itstick != _getSingleton().joySticks_.end(); itstick++)
+      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
+
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
+  {
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific joy stick handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific joy stick handler.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // look for the handler in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a joy stick handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+        return true;
+    }
+    return false;
+  }
+
+}
Index: /code/branches/network/src/core/input/InputManager.h
===================================================================
--- /code/branches/network/src/core/input/InputManager.h	(revision 1545)
+++ /code/branches/network/src/core/input/InputManager.h	(revision 1545)
@@ -0,0 +1,262 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "ois/OIS.h"
+#include "util/Math.h"
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+  /**
+  * Helper class to realise a vector<int[4]>
+  */
+  class POVStates
+  {
+  public:
+    int operator[](unsigned int index) { return povStates[index]; }
+    int povStates[4];
+  };
+
+  /**
+  * Helper class to realise a vector< {int[4], int[4]} >
+  */
+  class SliderStates
+  {
+  public:
+    IntVector2 sliderStates[4];
+  };
+
+  /**
+  * Struct for storing a custom input state
+  */
+  struct StoredState
+  {
+    std::vector<KeyHandler*>                    activeKeyHandlers_;
+    std::vector<MouseHandler*>                  activeMouseHandlers_;
+    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
+  };
+
+  struct JoyStickCalibration
+  {
+    int zeroStates[24];
+    float positiveCoeff[24];
+    float negativeCoeff[24];
+  };
+
+  /**
+    @brief Captures and distributes mouse and keyboard input.
+  */
+  class _CoreExport InputManager
+        : public OrxonoxClass,
+          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
+  {
+  public: // enumerations
+    /**
+      @brief Designates the way input is handled and redirected.
+    */
+    enum InputState
+    {
+      IS_UNINIT,    //!< InputManager has not yet been initialised.
+      IS_NONE,      //!< Input is discarded.
+      IS_NORMAL,    //!< Normal play state. Key and button bindings are active.
+      IS_GUI,       //!< All OIS input events are passed to CEGUI.
+      IS_CONSOLE,   //!< Keyboard input is redirected to the InputBuffer.
+      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
+      IS_NODETECT,  //!< remove KeyDetector
+      IS_NOCALIBRATE,
+      IS_CALIBRATE,
+      IS_CUSTOM     //!< Any possible configuration.
+    };
+
+  public: // member functions
+    void setConfigValues();
+
+  public: // static functions
+    static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
+    static bool initialiseKeyboard();
+    static bool initialiseMouse();
+    static bool initialiseJoySticks();
+    static int  numberOfKeyboards();
+    static int  numberOfMice();
+    static int  numberOfJoySticks();
+
+    static void destroy();
+    static void destroyKeyboard();
+    static void destroyMouse();
+    static void destroyJoySticks();
+
+    //static bool isModifierDown(KeyboardModifier::Enum modifier);
+    //static bool isKeyDown(KeyCode::Enum key);
+    //static const MouseState getMouseState();
+    //static const JoyStickState getJoyStickState(unsigned int ID);
+
+    static void setWindowExtents(const int width, const int height);
+
+    static void setInputState(const InputState state);
+    static InputState getInputState();
+
+    static void storeKeyStroke(const std::string& name);
+    static void keyBind(const std::string& command);
+
+    static void calibrate();
+
+    static void tick(float dt);
+
+    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
+    static bool removeKeyHandler              (const std::string& name);
+    static KeyHandler* getKeyHandler          (const std::string& name);
+    static bool enableKeyHandler              (const std::string& name);
+    static bool disableKeyHandler             (const std::string& name);
+    static bool isKeyHandlerActive            (const std::string& name);
+
+    static bool addMouseHandler               (MouseHandler* handler, const std::string& name);
+    static bool removeMouseHandler            (const std::string& name);
+    static MouseHandler* getMouseHandler      (const std::string& name);
+    static bool enableMouseHandler            (const std::string& name);
+    static bool disableMouseHandler           (const std::string& name);
+    static bool isMouseHandlerActive          (const std::string& name);
+
+    static bool addJoyStickHandler            (JoyStickHandler* handler, const std::string& name);
+    static bool removeJoyStickHandler         (const std::string& name);
+    static JoyStickHandler* getJoyStickHandler(const std::string& name);
+    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
+    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
+    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
+
+  private: // functions
+    // don't mess with a Singleton
+    InputManager ();
+    InputManager (const InputManager&);
+    ~InputManager();
+
+    // Intenal methods
+    bool _initialise(const size_t, int, int, bool, bool, bool);
+    bool _initialiseKeyboard();
+    bool _initialiseMouse();
+    bool _initialiseJoySticks();
+
+    void _destroy();
+    void _destroyKeyboard();
+    void _destroyMouse();
+    void _destroyJoySticks();
+
+    void _updateTickables();
+
+    void _saveState();
+    void _restoreState();
+
+    void _completeCalibration();
+
+    void _fireAxis(unsigned int iJoyStick, int axis, int value);
+    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
+
+    void _tick(float dt);
+
+    // input events
+    bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    bool mouseMoved    (const OIS::MouseEvent    &arg);
+    bool keyPressed    (const OIS::KeyEvent      &arg);
+    bool keyReleased   (const OIS::KeyEvent      &arg);
+    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+    //bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
+
+    static InputManager& _getSingleton();
+    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
+
+  private: // variables
+    OIS::InputManager*                          inputSystem_;     //!< OIS input manager
+    OIS::Keyboard*                              keyboard_;        //!< OIS mouse
+    OIS::Mouse*                                 mouse_;           //!< OIS keyboard
+    std::vector<OIS::JoyStick*>                 joySticks_;       //!< OIS joy sticks
+    unsigned int                                joySticksSize_;
+
+    KeyBinder*                                  keyBinder_;       //!< KeyBinder instance
+    KeyDetector*                                keyDetector_;     //!< KeyDetector instance
+    InputBuffer*                                buffer_;          //!< InputBuffer instance
+    CalibratorCallback*                         calibratorCallback_;
+
+    InputState state_;
+    InputState stateRequest_;
+    InputState savedState_;
+    unsigned int keyboardModifiers_;
+    StoredState savedHandlers_;
+
+    // joystick calibration
+    //std::vector<int> marginalsMaxConfig_;
+    //std::vector<int> marginalsMinConfig_;
+    int marginalsMax_[24];
+    int marginalsMin_[24];
+    bool bCalibrated_;
+
+    //! Keeps track of the joy stick POV states
+    std::vector<POVStates>                      povStates_;
+    //! Keeps track of the possibly two slider axes
+    std::vector<SliderStates>                   sliderStates_;
+    std::vector<JoyStickCalibration>            joySticksCalibration_;
+
+    std::map<std::string, KeyHandler*>          keyHandlers_;
+    std::map<std::string, MouseHandler*>        mouseHandlers_;
+    std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
+
+    std::vector<KeyHandler*>                    activeKeyHandlers_;
+    std::vector<MouseHandler*>                  activeMouseHandlers_;
+    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
+
+    std::vector<Key>                            keysDown_;
+    std::vector<MouseButton::Enum>              mouseButtonsDown_;
+    std::vector<std::vector<int> >              joyStickButtonsDown_;
+
+    static std::string                          bindingCommmandString_s;
+  };
+
+}
+
+#endif /* _InputManager_H__ */
Index: /code/branches/network/src/core/input/KeyBinder.cc
===================================================================
--- /code/branches/network/src/core/input/KeyBinder.cc	(revision 1545)
+++ /code/branches/network/src/core/input/KeyBinder.cc	(revision 1545)
@@ -0,0 +1,541 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/Debug.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.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" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
+		  joyStickButtons_[i + 1].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
+		  joyStickButtons_[i + 2].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
+		  joyStickButtons_[i + 3].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
+    }
+
+    // half axes
+    std::string rawNames[nHalfAxes_s/2];
+    rawNames[0] = "MouseX";
+    rawNames[1] = "MouseY";
+    rawNames[2] = "Empty1";
+    rawNames[3] = "Empty2";
+    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
+      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
+    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
+    {
+      halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
+      halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
+    }
+
+    for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
+      halfAxes_[i].buttonThreshold_ = buttonThreshold_;
+  }
+
+  /**
+    @brief Destructor
+  */
+  KeyBinder::~KeyBinder()
+  {
+    // almost no destructors required because most of the arrays are static.
+    clearBindings(); // does some destruction work
+  }
+
+  /**
+    @brief Loads the key and button bindings.
+    @return True if loading succeeded.
+  */
+  void KeyBinder::loadBindings()
+  {
+    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
+
+    clearBindings();
+
+    std::ifstream infile;
+    infile.open("keybindings.ini");
+    if (!infile)
+    {
+      ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "def_keybindings.ini");
+      ConfigFileManager::getSingleton()->save(CFT_Keybindings, "keybindings.ini");
+    }
+    else
+      infile.close();
+    ConfigFileManager::getSingleton()->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()
+  {
+    SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.01f)  .description("Threshold for analog axes until which the state is 0.");
+    SetConfigValueGeneric(KeyBinder, mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
+    SetConfigValueGeneric(KeyBinder, bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
+    SetConfigValueGeneric(KeyBinder, derivePeriod_, 0.5f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
+    SetConfigValueGeneric(KeyBinder, mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
+    SetConfigValueGeneric(KeyBinder, bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
+
+    float oldThresh = buttonThreshold_;
+    SetConfigValueGeneric(KeyBinder, 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_, "");
+      ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
+    }
+    std::string old = button.bindingString_;
+    cont->getValue(&button.bindingString_);
+
+    // keybinder stuff
+    if (old != button.bindingString_)
+    {
+      // clear everything so we don't get old axis ParamCommands mixed up
+      button.clear();
+
+      // binding has changed
+      button.parse(paramCommandBuffer_);
+    }
+  }
+
+  /**
+    @brief Overwrites all bindings with ""
+  */
+  void KeyBinder::clearBindings()
+  {
+    for (unsigned int i = 0; i < nKeys_s; i++)
+      keys_[i].clear();
+
+    for (unsigned int i = 0; i < nMouseButtons_s; i++)
+      mouseButtons_[i].clear();
+
+    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
+      joyStickButtons_[i].clear();
+
+    for (unsigned int i = 0; i < nHalfAxes_s; i++)
+      halfAxes_[i].clear();
+
+    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+      delete paramCommandBuffer_[i];
+    paramCommandBuffer_.clear();
+  }
+
+  void KeyBinder::resetJoyStickAxes()
+  {
+    for (unsigned int i = 8; i < nHalfAxes_s; i++)
+    {
+      halfAxes_[i].absVal_ = 0.0f;
+      halfAxes_[i].relVal_ = 0.0f;
+    }
+  }
+
+  void KeyBinder::tickInput(float dt, const HandlerState& state)
+  {
+    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
+    unsigned int iBegin = 8;
+    unsigned int iEnd   = 8;
+    if (state.joyStick)
+      iEnd = nHalfAxes_s;
+    if (state.mouse)
+      iBegin = 0;
+    for (unsigned int i = iBegin; i < iEnd; i++)
+    {
+      if (halfAxes_[i].hasChanged_)
+      {
+        if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
+        {
+          halfAxes_[i].wasDown_ = true;
+          if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
+            halfAxes_[i].execute(KeybindMode::OnPress);
+        }
+        else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
+        {
+          halfAxes_[i].wasDown_ = false;
+          if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
+            halfAxes_[i].execute(KeybindMode::OnRelease);
+        }
+        halfAxes_[i].hasChanged_ = false;
+      }
+
+      if (halfAxes_[i].wasDown_)
+      {
+        if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
+          halfAxes_[i].execute(KeybindMode::OnHold);
+      }
+
+      // these are the actually useful axis bindings for analog input AND output
+      if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
+      {
+        //COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl;
+        halfAxes_[i].execute();
+      }
+    }
+
+    if (bDeriveMouseInput_ && state.mouse)
+    {
+      if (deriveTime_ > derivePeriod_)
+      {
+        //CCOUT(3) << "mouse abs: ";
+        for (int i = 0; i < 2; i++)
+        {
+          if (mouseRelative_[i] > 0)
+          {
+            halfAxes_[2*i + 0].absVal_ =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+            halfAxes_[2*i + 1].absVal_ = 0.0f;
+          }
+          else if (mouseRelative_[i] < 0)
+          {
+            halfAxes_[2*i + 0].absVal_ = 0.0f;
+            halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+          }
+          else
+          {
+            halfAxes_[2*i + 0].absVal_ = 0.0f;
+            halfAxes_[2*i + 1].absVal_ = 0.0f;
+          }
+          //COUT(3) << mouseRelative_[i] << " | ";
+          mouseRelative_[i] = 0;
+          halfAxes_[2*i + 0].hasChanged_ = true;
+          halfAxes_[2*i + 1].hasChanged_ = true;
+        }
+        deriveTime_ = 0.0f;
+        //COUT(3) << std::endl;
+      }
+      else
+        deriveTime_ += dt;
+    }
+
+    // execute all buffered bindings (addional parameter)
+    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+      paramCommandBuffer_[i]->execute();
+
+    // always reset the relative movement of the mouse
+    if (state.mouse)
+      for (unsigned int i = 0; i < 8; i++)
+        halfAxes_[i].relVal_ = 0.0f;
+  }
+
+  void KeyBinder::keyPressed (const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::keyReleased(const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::keyHeld    (const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnHold); }
+
+
+  void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnHold); }
+
+
+  void KeyBinder::joyStickButtonPressed (int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::joyStickButtonReleased(int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::joyStickButtonHeld    (int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnHold); }
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Mouse state information
+  */
+  void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
+  {
+    // y axis of mouse input is inverted
+    int rel[] = { rel_.x, -rel_.y };
+
+    if (!bDeriveMouseInput_)
+    {
+      for (int i = 0; i < 2; i++)
+      {
+        if (rel[i])
+        {
+          // absolute
+          halfAxes_[2*i + 0].hasChanged_ = true;
+          halfAxes_[2*i + 1].hasChanged_ = true;
+          mousePosition_[i] += rel[i];
+
+          if (bClipMouse_)
+          {
+            if (mousePosition_[i] > 1024)
+              mousePosition_[i] =  1024;
+            if (mousePosition_[i] < -1024)
+              mousePosition_[i] = -1024;
+          }
+
+          if (mousePosition_[i] >= 0)
+          {
+            halfAxes_[2*i + 0].absVal_ =   mousePosition_[i]/1024.0f * mouseSensitivity_;
+            halfAxes_[2*i + 1].absVal_ =  0.0f;
+          }
+          else
+          {
+            halfAxes_[2*i + 0].absVal_ =  0.0f;
+            halfAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/1024.0f * mouseSensitivity_;
+          }
+        }
+      }
+    }
+    else
+    {
+      mouseRelative_[0] += rel[0];
+      mouseRelative_[1] += rel[1];
+    }
+
+    // relative
+    for (int i = 0; i < 2; i++)
+    {
+      if (rel[i] > 0)
+        halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
+      else
+        halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
+    }
+  }
+
+  /**
+    @brief Event handler for the mouseScrolled Event.
+    @param e Mouse state information
+  */
+  void KeyBinder::mouseScrolled(int abs, int rel)
+  {
+    //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
+
+    if (rel > 0)
+      for (int i = 0; i < rel/120; i++)
+        mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+    else
+      for (int i = 0; i < -rel/120; i++)
+        mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+  }
+
+  void KeyBinder::joyStickAxisMoved(int joyStickID, int axis, float value)
+  {
+    // TODO: Use proper calibration values instead of generally 16-bit integer
+    int i = 8 + axis * 2;
+    if (value >= 0)
+    {
+      //if (value > 10000)
+      //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; }
+
+      halfAxes_[i].absVal_ = value;
+      halfAxes_[i].relVal_ = value;
+      halfAxes_[i].hasChanged_ = true;
+      if (halfAxes_[i + 1].absVal_ > 0.0f)
+      {
+        halfAxes_[i + 1].absVal_ = -0.0f;
+        halfAxes_[i + 1].relVal_ = -0.0f;
+        halfAxes_[i + 1].hasChanged_ = true;
+      }
+    }
+    else
+    {
+      //if (value < -10000)
+      //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; }
+
+      halfAxes_[i + 1].absVal_ = -value;
+      halfAxes_[i + 1].relVal_ = -value;
+      halfAxes_[i + 1].hasChanged_ = true;
+      if (halfAxes_[i].absVal_ > 0.0f)
+      {
+        halfAxes_[i].absVal_ = -0.0f;
+        halfAxes_[i].relVal_ = -0.0f;
+        halfAxes_[i].hasChanged_ = true;
+      }
+    }
+  }
+}
Index: /code/branches/network/src/core/input/KeyBinder.h
===================================================================
--- /code/branches/network/src/core/input/KeyBinder.h	(revision 1545)
+++ /code/branches/network/src/core/input/KeyBinder.h	(revision 1545)
@@ -0,0 +1,143 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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, const HandlerState& state);
+
+    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 (int joyStickID, int button);
+    void joyStickButtonReleased(int joyStickID, int button);
+    void joyStickButtonHeld    (int joyStickID, int button);
+    void joyStickAxisMoved     (int joyStickID, 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];
+
+    /**
+    * 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/network/src/core/input/KeyDetector.cc
===================================================================
--- /code/branches/network/src/core/input/KeyDetector.cc	(revision 1545)
+++ /code/branches/network/src/core/input/KeyDetector.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the different input handlers.
+ */
+
+#include "KeyDetector.h"
+#include "core/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()
+  {
+    clearBindings();
+    setConfigValues();
+  }
+
+  void KeyDetector::readTrigger(Button& button)
+  {
+    SimpleCommand* cmd = new SimpleCommand();
+    cmd->evaluation_ = CommandExecutor::evaluate("storeKeyStroke " + button.name_);
+    button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
+    button.commands_[KeybindMode::OnPress][0] = cmd;
+    button.nCommands_[KeybindMode::OnPress] = 1;
+  }
+}
Index: /code/branches/network/src/core/input/KeyDetector.h
===================================================================
--- /code/branches/network/src/core/input/KeyDetector.h	(revision 1545)
+++ /code/branches/network/src/core/input/KeyDetector.h	(revision 1545)
@@ -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 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();
+
+  protected:
+    void readTrigger(Button& button);
+  };
+}
+
+#endif /* _KeyDetector_H__ */
Index: /code/branches/network/src/core/tolua/tolua.pkg
===================================================================
--- /code/branches/network/src/core/tolua/tolua.pkg	(revision 1545)
+++ /code/branches/network/src/core/tolua/tolua.pkg	(revision 1545)
@@ -0,0 +1,1 @@
+$cfile "../../src/core/Script_clean.h"
Index: /code/branches/network/src/cpptcl/CMakeLists.txt
===================================================================
--- /code/branches/network/src/cpptcl/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/cpptcl/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,5 @@
+ADD_LIBRARY(cpptcl SHARED CppTcl.cc)
+
+TARGET_LINK_LIBRARIES(cpptcl
+  ${TCL_LIBRARY}
+)
Index: /code/branches/network/src/cpptcl/CREDITS
===================================================================
--- /code/branches/network/src/cpptcl/CREDITS	(revision 1545)
+++ /code/branches/network/src/cpptcl/CREDITS	(revision 1545)
@@ -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/network/src/cpptcl/CppTcl.cc
===================================================================
--- /code/branches/network/src/cpptcl/CppTcl.cc	(revision 1545)
+++ /code/branches/network/src/cpptcl/CppTcl.cc	(revision 1545)
@@ -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/network/src/cpptcl/CppTcl.h
===================================================================
--- /code/branches/network/src/cpptcl/CppTcl.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/CppTcl.h	(revision 1545)
@@ -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/network/src/cpptcl/LICENSE
===================================================================
--- /code/branches/network/src/cpptcl/LICENSE	(revision 1545)
+++ /code/branches/network/src/cpptcl/LICENSE	(revision 1545)
@@ -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/network/src/cpptcl/README
===================================================================
--- /code/branches/network/src/cpptcl/README	(revision 1545)
+++ /code/branches/network/src/cpptcl/README	(revision 1545)
@@ -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/network/src/cpptcl/details/callbacks.h
===================================================================
--- /code/branches/network/src/cpptcl/details/callbacks.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/callbacks.h	(revision 1545)
@@ -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/network/src/cpptcl/details/callbacks_v.h
===================================================================
--- /code/branches/network/src/cpptcl/details/callbacks_v.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/callbacks_v.h	(revision 1545)
@@ -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/network/src/cpptcl/details/constructors.h
===================================================================
--- /code/branches/network/src/cpptcl/details/constructors.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/constructors.h	(revision 1545)
@@ -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/network/src/cpptcl/details/conversions.h
===================================================================
--- /code/branches/network/src/cpptcl/details/conversions.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/conversions.h	(revision 1545)
@@ -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/network/src/cpptcl/details/dispatchers.h
===================================================================
--- /code/branches/network/src/cpptcl/details/dispatchers.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/dispatchers.h	(revision 1545)
@@ -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/network/src/cpptcl/details/metahelpers.h
===================================================================
--- /code/branches/network/src/cpptcl/details/metahelpers.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/metahelpers.h	(revision 1545)
@@ -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/network/src/cpptcl/details/methods.h
===================================================================
--- /code/branches/network/src/cpptcl/details/methods.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/methods.h	(revision 1545)
@@ -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/network/src/cpptcl/details/methods_v.h
===================================================================
--- /code/branches/network/src/cpptcl/details/methods_v.h	(revision 1545)
+++ /code/branches/network/src/cpptcl/details/methods_v.h	(revision 1545)
@@ -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/network/src/network/CMakeLists.txt
===================================================================
--- /code/branches/network/src/network/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/network/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,182 @@
+SET( NETWORK_SRC_FILES
+  Client.cc
+  ClientConnection.cc
+  ClientInformation.cc
+  ConnectionManager.cc
+  GameStateManager.cc
+  GameStateClient.cc
+  PacketBuffer.cc
+  PacketDecoder.cc
+  PacketGenerator.cc
+  Server.cc
+  Synchronisable.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
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    diffTest.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc  
+  )
+
+  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)
+# build this if you want dummyserver4 and dummyclient4
+IF(NETWORKTRAFFIC_TESTING_ENABLED)
+  ##### test network traffic #####
+  SET( DUMMYSERVER4_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc
+    dummyserver4.cc
+  )
+
+  SET( DUMMYCLIENT4_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc
+    dummyclient4.cc
+  )
+
+  ADD_EXECUTABLE(dummyserver4 ${DUMMYSERVER4_SRC_FILES})
+  TARGET_LINK_LIBRARIES( dummyserver4
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+    ${Boost_thread_LIBRARIES}
+    core
+    orxonoxs
+    audio
+  )
+
+  ADD_EXECUTABLE(dummyclient4 ${DUMMYCLIENT4_SRC_FILES})
+  TARGET_LINK_LIBRARIES( dummyclient4
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+    ${Boost_thread_LIBRARIES}
+    core
+    orxonoxs
+    audio
+  )
+ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+IF(BLABLA)
+  SET( CHATCLIENT_SRC_FILES
+    ClientConnection.cc
+    Client.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    dummyclient3.cc
+  )
+
+  SET( CHATSERVER_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    dummyserver3.cc
+  )
+
+  # chatserver for testing purposes
+  ADD_EXECUTABLE(chatserver ${CHATSERVER_SRC_FILES})
+  TARGET_LINK_LIBRARIES( chatserver
+    ${OGRE_LIBRARIES}
+    network
+    core
+    #objects
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+
+  # chatclient for testing purpose
+  ADD_EXECUTABLE(chatclient ${CHATCLIENT_SRC_FILES})
+  TARGET_LINK_LIBRARIES( chatclient
+    ${OGRE_LIBRARIES}
+    network
+    core
+    #objects
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+
+  # client for testing purpose
+  ADD_EXECUTABLE(client dummyclient2.cc)
+  TARGET_LINK_LIBRARIES( client
+    ${OGRE_LIBRARIES}
+    network
+    core
+    #objects
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+
+  # server for testing purpose
+  ADD_EXECUTABLE(server dummyserver.cc)
+  TARGET_LINK_LIBRARIES( server
+    ${OGRE_LIBRARIES}
+    network
+    core
+    #objects
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+ENDIF(BLABLA)
+
Index: /code/branches/network/src/network/Client.cc
===================================================================
--- /code/branches/network/src/network/Client.cc	(revision 1545)
+++ /code/branches/network/src/network/Client.cc	(revision 1545)
@@ -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:
+ *      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 "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "Server.h"
+
+namespace network
+{
+  SetConsoleCommandShortcut(Client, Chat);
+  
+  Client* Client::_sClient = 0;
+  
+  Client* Client::createSingleton(){
+    if(!_sClient){
+      _sClient = new Client();
+    }
+    return _sClient;
+  }
+  
+  Client* Client::createSingleton(std::string address, int port){
+    if(!_sClient)
+      _sClient = new Client(address, port);
+    return _sClient;
+  }
+  
+  Client* Client::createSingleton(const char *address, int port){
+    if(!_sClient)
+      _sClient = new Client(address, port);
+    return _sClient;
+  }
+  
+  void Client::destroySingleton(){
+    if(_sClient){
+      delete _sClient;
+      _sClient = 0;
+    }
+  }
+  
+  Client* Client::getSingleton(){
+    return _sClient; 
+  }
+  
+  /**
+  * 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;
+  }
+
+  /**
+  * 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;
+  }
+
+  /**
+  * 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;
+  }
+
+  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(3) << "sending connectrequest" << std::endl;
+//       if(!client_connection.addPacket(pck_gen.generateConnectRequest()) || !client_connection.sendPackets())
+//         COUT(1) << "could not send connection request !!!!!!!!!" << std::endl;
+    }else
+      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();
+  }
+
+  
+
+  void Client::Chat( std::string message ){
+    if(Client::getSingleton())
+      Client::getSingleton()->sendChat(message);
+    else if(Server::getSingleton())
+      Server::getSingleton()->sendChat(message);
+    else
+      COUT(1) << "do you want to monologize ??" << std::endl;
+  }
+  
+
+  /**
+  * 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;
+    return client_connection.addPacket(pck_gen.chatMessage( message.c_str() ));
+      //return client_connection.sendPackets();
+    // send packets
+    return false;
+  }
+
+  /**
+  * Performs a GameState update
+  */
+  void Client::tick(float time){
+//     COUT(3) << ".";
+    if(client_connection.isConnected() && isSynched_){
+      COUT(4) << "popping partial gamestate: " << std::endl;
+      GameStateCompressed *gs = gamestate.popPartialGameState();
+      if(gs){
+        COUT(4) << "client tick: sending gs " << gs << std::endl;
+        ENetPacket *packet = pck_gen.gstate(gs);
+        if( packet == NULL || !client_connection.addPacket(packet))
+          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+        // now delete it to save memory
+        delete[] gs->data;
+        delete gs;
+      }
+    }
+    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;
+      elaborate(event->packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
+    }
+    int gameStateID = gamestate.processGameState();
+    if(gameStateID==GAMESTATEID_INITIAL)
+      if(gameStateFailure_){
+        if(!client_connection.addPacket(pck_gen.acknowledgement(GAMESTATEID_INITIAL)))
+          COUT(3) << "could not (negatively) ack gamestate" << std::endl;
+        else 
+          COUT(4) << "negatively acked a gamestate" << std::endl;
+        }
+      else
+        gameStateFailure_=true;
+    else if(gameStateID!=0){
+      // ack gamestate and set synched
+      if(!isSynched_)
+        isSynched_=true;
+      gameStateFailure_=false;
+      if(!client_connection.addPacket(pck_gen.acknowledgement(gameStateID)))
+        COUT(3) << "could not ack gamestate" << std::endl;
+    }// otherwise we had no gamestate to load
+    gamestate.cleanup();
+    /*if(!client_connection.sendPackets())
+      COUT(3) << "Problem sending packets to server" << std::endl;*/
+    return;
+  }
+
+  void Client::processGamestate( GameStateCompressed *data, int clientID){
+    COUT(5) << "received gamestate id: " << data->id << std::endl;
+    gamestate.addGameState(data);
+  }
+
+  void Client::processClassid(classid *clid){
+    orxonox::Identifier *id;
+    id=ID(std::string(clid->message));
+    if(id!=NULL)
+      id->setNetworkID(clid->clid);
+    COUT(4) << "Client: received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
+    COUT(4) << "id(classid)->getName " << ID((unsigned int)clid->clid)->getName() << std::endl;
+    delete clid;
+    return;
+  }
+
+  void Client::processChat( chat *data, int clientId){
+    COUT(1) << data->message << std::endl;
+    delete[] data->message;
+    delete data;
+  }
+  
+  bool Client::processWelcome( welcome *w ){
+    COUT(4) << "processing welcome message" << std::endl;
+    clientID_ = w->clientID;
+    shipID_ = w->shipID;
+    delete w;
+    return true;
+  }
+
+}
Index: /code/branches/network/src/network/Client.h
===================================================================
--- /code/branches/network/src/network/Client.h	(revision 1545)
+++ /code/branches/network/src/network/Client.h	(revision 1545)
@@ -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: 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 "ClientConnection.h"
+#include "PacketManager.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 : PacketDecoder{
+  public:
+    
+    static Client* createSingleton();
+    static Client* createSingleton(std::string address, int port);
+    static Client* createSingleton(const char *address, int port);
+    static void destroySingleton();
+    static Client *getSingleton();
+    
+    bool establishConnection();
+    bool closeConnection();
+
+    static void Chat( std::string message );
+    
+    int getShipID(){return shipID_;}
+    int getClientID(){return clientID_;}
+
+    void tick(float time);
+
+  private:
+    Client();
+    Client(std::string address, int port);
+    Client(const char *address, int port);
+    ~Client();
+    
+    static Client* _sClient;
+    
+    ClientConnection client_connection;
+    PacketGenerator pck_gen;
+    GameStateClient gamestate;
+    bool isConnected;
+    bool isSynched_;
+
+    bool sendChat( std::string message );
+    
+    // implement data processing functions of PacketDecoder
+    void processGamestate( GameStateCompressed *data, int clientID);
+    void processClassid(classid *clid);
+    void processChat( chat *data, int clientId );
+    bool processWelcome( welcome *w );
+    int clientID_;     // this is the id the server gave to us
+    int shipID_;
+    bool gameStateFailure_;
+  };
+
+
+}
+
+#endif /* _Client_H__ */
Index: /code/branches/network/src/network/ClientConnection.cc
===================================================================
--- /code/branches/network/src/network/ClientConnection.cc	(revision 1545)
+++ /code/branches/network/src/network/ClientConnection.cc	(revision 1545)
@@ -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:
+ *      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/bind.hpp>
+
+#include "util/Sleep.h"
+#include "core/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/network/src/network/ClientConnection.h
===================================================================
--- /code/branches/network/src/network/ClientConnection.h	(revision 1545)
+++ /code/branches/network/src/network/ClientConnection.h	(revision 1545)
@@ -0,0 +1,111 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/thread.hpp>
+
+#include "PacketBuffer.h"
+
+namespace network
+{
+
+#define NETWORK_PORT 55556
+#define NETWORK_CLIENT_MAX_CONNECTIONS 5
+#define NETWORK_CLIENT_WAIT_TIME 1
+#define NETWORK_CLIENT_CONNECT_TIMEOUT 3000 // miliseconds
+#define 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/network/src/network/ClientInformation.cc
===================================================================
--- /code/branches/network/src/network/ClientInformation.cc	(revision 1545)
+++ /code/branches/network/src/network/ClientInformation.cc	(revision 1545)
@@ -0,0 +1,308 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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() {
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    this->head_=false;
+    synched_=false;
+  }
+
+  ClientInformation::ClientInformation(bool head) {
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    this->head_=head;
+    synched_=false;
+  }
+
+  // ClientInformation::ClientInformation(ClientInformation *prev) {
+  //   if(prev->next()!=0){
+  //     this->nexte=prev->next();
+  //     this->nexte->setPrev(this);
+  //   }
+  //   else
+  //     this->nexte = 0;
+  //   prev->setNext(this);
+  //   this->preve = pref;
+  // }
+  //
+  // ClientInformation::ClientInformation(ClientInformation *prev, ClientInformation *next){
+  //   this->nexte = next;
+  //   this->preve = prev;
+  //   this->preve->setNext(this);
+  //   this->nexte->setPrev(this);
+  // }
+
+  ClientInformation::~ClientInformation() {
+    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(!head_)
+      this->preve = prev;
+    else
+      return false;
+    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;
+  }
+  
+  bool ClientInformation::getHead(){
+    return head_;
+  }
+  
+  void ClientInformation::setHead(bool h){
+    head_=h;
+  }
+  
+  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) {
+    if(!this)
+      return NULL;
+    ClientInformation *temp = this;
+    while(temp->next()!=0){
+      temp = temp->next();
+    }
+    temp->setNext(ins);
+    ins->setPrev(temp);
+    return ins;
+  }
+
+  bool ClientInformation::removeClient(int clientID) {
+    if(!this || clientID==CLIENTID_UNKNOWN)
+      return false;
+    ClientInformation *temp = this;
+    while(temp!=0 && temp->getID()!=clientID)
+      temp = temp->next();
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  bool ClientInformation::removeClient(ENetPeer *peer) {
+    if(!this || !peer)
+      return false;
+    ClientInformation *temp = this;
+    while(temp!=0){
+      if(!temp->head_)
+        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 = this;
+    if (temp->head_)
+      temp=temp->next();
+    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 = this;
+    while(temp!=0){
+      if(temp->head_){
+        temp = temp->next();
+        continue;
+      }
+      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/network/src/network/ClientInformation.h
===================================================================
--- /code/branches/network/src/network/ClientInformation.h	(revision 1545)
+++ /code/branches/network/src/network/ClientInformation.h	(revision 1545)
@@ -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:
+ *      ...
+ *   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(bool head);
+    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
+    //   ClientInformation(ClientInformation *prev);
+    ~ClientInformation();
+    ClientInformation *next();
+    ClientInformation *prev();
+    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(int id){ShipID_=id;}
+    
+    // get functions
+    inline int getShipID(){return ShipID_;}
+    int getID();
+    int getGamestateID();
+    int getPartialGamestateID();
+    ENetPeer *getPeer();
+    bool getHead();
+    void setHead(bool h);
+    
+    int getFailures();
+    void addFailure();
+    void resetFailures();
+    enet_uint32 getRTT();
+    enet_uint32 getPacketLoss();
+    
+    bool removeClient(int clientID);
+    bool removeClient(ENetPeer *peer);
+    //## add bool mask-function eventually
+    ClientInformation *findClient(int clientID, bool look_backwards=false);
+    //## add bool mask-function eventually
+    ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
+
+    bool setSynched(bool s);
+    bool getSynched();
+
+
+    private:
+      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_;
+    int ShipID_;   // this is the unique objectID
+    bool synched_;
+    bool head_;
+    unsigned short failures_;
+    
+  };
+
+}
+
+#endif /* _ClientInformation_H__ */
Index: /code/branches/network/src/network/ConnectionManager.cc
===================================================================
--- /code/branches/network/src/network/ConnectionManager.cc	(revision 1545)
+++ /code/branches/network/src/network/ConnectionManager.cc	(revision 1545)
@@ -0,0 +1,374 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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>
+// boost.thread library for multithreading support
+#include <boost/bind.hpp>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "objects/SpaceShip.h"
+#include "util/Math.h"
+#include "util/Sleep.h"
+#include "ClientInformation.h"
+#include "ConnectionManager.h"
+#include "Synchronisable.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():receiverThread_(0){}
+  boost::recursive_mutex ConnectionManager::enet_mutex_;
+  
+  ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = NETWORK_PORT;
+    head_ = head;
+  }
+  
+  ConnectionManager::ConnectionManager(ClientInformation *head, int port){
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = port;
+    head_ = head;
+  }
+
+  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) :receiverThread_(0) {
+    quit=false;
+    enet_address_set_host (& bindAddress, address.c_str());
+    bindAddress.port = NETWORK_PORT;
+    head_ = head;
+  }
+
+  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) : receiverThread_(0) {
+    quit=false;
+    enet_address_set_host (& bindAddress, address);
+    bindAddress.port = NETWORK_PORT;
+    head_ = head;
+  }
+
+  /*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(ENetPacket *packet, ENetPeer *peer) {
+    ClientInformation *temp = head_->findClient(&(peer->address));
+    if(!temp)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    if(enet_peer_send(peer, (enet_uint8)temp->getID() , packet)!=0)
+      return false;
+    return true;
+  }
+
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
+    ClientInformation *temp = head_->findClient(clientID);
+    if(!temp){
+      COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+      return false;
+    }
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    if(enet_peer_send(temp->getPeer(), 0, packet)!=0){
+      COUT(3) << "C.Man: addPacket enet_peer_send failed" << std::endl;
+      return false;
+    }
+    return true;
+  }
+
+  bool ConnectionManager::addPacketAll(ENetPacket *packet) {
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    for(ClientInformation *i=head_->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)
+      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 = head_->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 = head_->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(head_->findClient(&(event.peer->address)))
+          delete head_->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 head_->findClient(&address)->getID();
+  }
+
+  ENetPeer *ConnectionManager::getClientPeer(int clientID) {
+    return head_->findClient(clientID)->getPeer();
+  }
+
+  void ConnectionManager::syncClassid(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;
+
+      while(!addPacket(packet_gen.clid( (int)network_id, classname ), clientID) && failures < 10){
+        failures++;
+      }
+      ++it;
+    }
+    //sendPackets();
+    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+  }
+
+  
+  
+  bool ConnectionManager::removeShip(ClientInformation *client){
+    int id=client->getShipID();
+    orxonox::Iterator<orxonox::SpaceShip> it;
+    for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){
+      if(it->objectID!=id)
+        continue;
+      delete *it;
+    }
+    return true;
+  }
+  
+  bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){
+    if(addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID)){
+      //sendPackets();
+      return true;
+    }else
+      return false;
+  }
+  
+  void ConnectionManager::disconnectClient(ClientInformation *client){
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      enet_peer_disconnect(client->getPeer(), 0);
+      lock.unlock();
+    }
+    removeShip(client);
+  }
+  
+  bool ConnectionManager::addFakeConnectRequest(ENetEvent *ev){
+    ENetEvent event;
+    event.peer=ev->peer;
+    event.packet = packet_gen.generateConnectRequest();
+    return buffer.push(&event);
+  }
+  
+  
+
+}
Index: /code/branches/network/src/network/ConnectionManager.h
===================================================================
--- /code/branches/network/src/network/ConnectionManager.h	(revision 1545)
+++ /code/branches/network/src/network/ConnectionManager.h	(revision 1545)
@@ -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:
+ *      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/thread.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+
+#include "PacketBuffer.h"
+#include "PacketManager.h"
+
+namespace std
+{
+  bool operator<(ENetAddress a, ENetAddress b);
+}
+
+namespace network
+{
+#define NETWORK_PORT 55556
+#define NETWORK_MAX_CONNECTIONS 50
+#define NETWORK_WAIT_TIMEOUT 1
+
+  struct ClientList{
+    ENetEvent *event;
+    int ID;
+    ClientList *next;
+  };
+
+  class ConnectionManager{
+  public:
+    ConnectionManager();
+    ConnectionManager(ClientInformation *head);
+    ConnectionManager(ClientInformation *head, int port);
+    ConnectionManager(int port, const char *address, ClientInformation *head);
+    ConnectionManager(int port, std::string address, ClientInformation *head);
+    //ENetPacket *getPacket(ENetAddress &address); // thread1
+    //ENetPacket *getPacket(int &clientID);
+    ENetEvent *getEvent();
+    bool queueEmpty();
+    void createListener();
+    bool quitListener();
+    bool addPacket(ENetPacket *packet, ENetPeer *peer);
+    bool addPacket(ENetPacket *packet, int ID);
+    bool addPacketAll(ENetPacket *packet);
+  //  bool sendPackets(ENetEvent *event);
+    bool sendPackets();
+    //bool createClient(int clientID);
+    void disconnectClient(ClientInformation *client);
+    void syncClassid(int clientID);
+    bool sendWelcome(int clientID, int shipID, bool allowed);
+
+  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);
+    bool addFakeConnectRequest(ENetEvent *ev);
+    PacketBuffer buffer;
+    PacketGenerator packet_gen;
+
+    ENetHost *server;
+    ENetAddress bindAddress;
+
+    bool quit; // quit-variable (communication with threads)
+    ClientInformation *head_;
+
+    boost::thread *receiverThread_;
+    static boost::recursive_mutex enet_mutex_;
+//     int getNumberOfClients();
+    //functions to map what object every clients uses
+    /*std::map<int, int> clientsShip;
+    void addClientsObjectID( int clientID, int objectID );
+    int getClientsShipID( int clientID );
+    int getObjectsClientID( int objectID );
+    void deleteClientIDReg( int clientID );
+    void deleteObjectIDReg( int objectID );*/
+  };
+
+}
+
+#endif /* _ConnectionManager_H__ */
Index: /code/branches/network/src/network/GameStateClient.cc
===================================================================
--- /code/branches/network/src/network/GameStateClient.cc	(revision 1545)
+++ /code/branches/network/src/network/GameStateClient.cc	(revision 1545)
@@ -0,0 +1,480 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "Synchronisable.h"
+
+
+namespace network
+{
+  struct GameStateItem{
+    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::pushGameState(GameStateCompressed *compstate) {
+    cleanup();
+    printGameStateMap();
+    GameState *gs, *reference;
+    /*if(compstate->id<last_gamestate_){
+      // network packets got messed up
+      COUT(3) << "received an obsolete gamestate" << std::endl;
+      return false;
+    }*/
+    if(compstate->diffed && compstate->base_id!=GAMESTATEID_INITIAL){
+      std::map<int, GameState*>::iterator it = gameStateMap.find(compstate->base_id);
+      if(it!=gameStateMap.end())
+        reference = (it)->second;
+      else
+        reference = NULL;
+      if(!reference){
+        COUT(4) << "pushGameState: no reference found to diff" << std::endl;
+        delete[] compstate->data;
+        delete compstate;
+        return false;
+      }
+      gs = decode(reference, compstate);
+    }
+    else
+      gs = decode(compstate);
+    if(gs){
+      if (loadSnapshot(gs)){
+        gameStateMap.insert(std::pair<int, GameState*>(gs->id, gs));
+        COUT(5) << "adding decoded gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
+        last_diff_=gs->base_id;
+        //last_gamestate_=gs->id;
+        return true;
+      }else{
+        COUT(4) << "could not decode gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
+        delete[] gs->data;
+        delete gs;
+        return false;
+      }
+    }
+    COUT(4) << "could not use gamestate sent by server" << std::endl;
+    return false;
+  }
+
+  GameStateCompressed *GameStateClient::popPartialGameState(){
+    GameState *gs = getPartialSnapshot();
+    if(!gs)
+      return NULL;
+    GameStateCompressed *cgs = compress_(gs);
+    delete[] gs->data;
+    delete gs;
+    return cgs;
+  }
+
+  void GameStateClient::addGameState(GameStateCompressed *gs){
+    if(tempGameState_!=NULL){
+      //delete the obsolete gamestate
+      if(tempGameState_->id>gs->id)
+        return;
+      delete[] tempGameState_->data;
+      delete tempGameState_;
+    }
+    tempGameState_=gs;
+  }
+  int GameStateClient::processGameState(){
+    if(tempGameState_==NULL)
+      return 0;
+    int id=tempGameState_->id;
+    bool b = saveShipCache();
+    if(pushGameState(tempGameState_)){
+      if(b)
+        loadShipCache();
+      return id;
+    }
+    else
+      return GAMESTATEID_INITIAL;
+  }
+
+
+  /**
+  * 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::Iterator<Synchronisable> &it) {
+    orxonox::Iterator<Synchronisable> temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  /**
+  * This function loads a Snapshort of the gamestate into the universe
+  * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
+  */
+  bool GameStateClient::loadSnapshot(GameState *state) {
+    unsigned char *data=state->data;
+    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
+    syncData sync;
+    // loop as long as we have some data ;)
+    while(data < state->data+state->size){
+      // prepare the syncData struct
+      sync.length = *(int *)data;
+      data+=sizeof(int);
+      sync.objectID = *(int*)data;
+      data+=sizeof(int);
+      sync.classID = *(int*)data;
+      data+=sizeof(int);
+      sync.data = data;
+      data+=sync.length;
+
+      if(!it || it->objectID!=sync.objectID){
+        // bad luck ;)
+        // delete the synchronisable (obviously seems to be deleted on the server)
+        while(it && it->objectID!=sync.objectID)
+          removeObject(it);
+
+
+        if(!it){
+          //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
+          ///sigsegv may happen here again for some reason
+          ///sigsegv is receved after the COUT(4) above
+          orxonox::Identifier* id = ID((unsigned int)sync.classID);
+          if(!id){
+            COUT(3) << "We could not identify a new object; classid: " << sync.classID << " uint: " << (unsigned int)sync.classID << " objectID: " << sync.objectID << " size: " << sync.length << std::endl;
+            return false; // most probably the gamestate is corrupted
+          }
+          Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
+          COUT(4) << "loadsnapshot: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
+          if(!no){
+            COUT(2) << "coudl not frabricate classid: " << sync.classID << " objectID: " << sync.objectID << " identifier: " << id << std::endl;
+            break;
+          }
+          no->objectID=sync.objectID;
+          no->classID=sync.classID;
+          // update data and create object/entity...
+          if( !no->updateData(sync) ){
+            COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
+            return false;
+          }
+          if( !no->create() )
+          {
+            COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
+          }
+          it=orxonox::ObjectList<Synchronisable>::end();
+        }
+      } else {
+        // we have our object
+        if(! it->updateData(sync))
+        {
+          COUT(1) << "We couldn't update objectID: " \
+          << sync.objectID << "; classID: " << sync.classID << std::endl;
+        }
+      }
+      ++it;
+    }
+
+    return true;
+  }
+
+  GameState *GameStateClient::getPartialSnapshot(){
+    //std::cout << "begin getSnapshot" << std::endl;
+    //the size of the gamestate
+    int totalsize=0;
+    int memsize=0;
+    //the size of one specific synchronisable
+    int tempsize=0;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it;
+    // struct for return value of Synchronisable::getData()
+    syncData sync;
+
+    GameState *retval=new GameState; //return value
+//     retval->id=reference->id;
+    if(gameStateMap.size()!=0)
+      retval->id=(--gameStateMap.end())->second->id;
+    retval->diffed=false;
+    retval->complete=false;
+    COUT(4) << "G.ST.Client: producing partial gamestate with id: " << retval->id << std::endl;
+    // offset of memory functions
+    int offset=0, size=0;
+    // get total size of gamestate
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      if(!it->getBacksync())
+        continue;
+      size+=it->getSize(); // size of the actual data of the synchronisable
+      size+=3*sizeof(int); // size of datasize, classID and objectID
+      COUT(5) << "getpartialsnapshot: size: " << size << std::endl;
+    }
+    //retval->data = (unsigned char*)malloc(size);
+    if(size==0)
+      return NULL;
+    retval->data = new unsigned char[size];
+    if(!retval->data){
+      COUT(2) << "GameStateClient: could not allocate memory" << std::endl;
+      return NULL;
+    }
+    memsize=size;
+    // go through all Synchronisables
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      if(!it->getBacksync())
+        continue;
+      //get size of the synchronisable
+      tempsize=it->getSize();
+      // add place for data and 3 ints (length,classid,objectid)
+      totalsize+=tempsize+3*sizeof(int);
+      // allocate+tempsize additional space
+      if(totalsize > size){
+        COUT(3) << "G.St.Cl: need additional memory" << std::endl;
+      }
+
+      // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
+      sync=it->getData((retval->data)+offset+3*sizeof(int));
+      memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int));
+      memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int));
+      memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int));
+      // increase data pointer
+      offset+=tempsize+3*sizeof(int);
+    }
+    retval->size=totalsize;
+    COUT(5) << "G.ST.Cl: Gamestate size: " << totalsize << std::endl;
+    COUT(5) << "G.ST.Cl: 'estimated' Gamestate size: " << size << std::endl;
+    return retval;
+  }
+
+
+  GameState *GameStateClient::undiff(GameState *old, GameState *diff) {
+    if(!old || !diff)
+      return NULL;
+    unsigned char *ap = old->data, *bp = diff->data;
+    int of=0; // pointers offset
+    int dest_length=0;
+    /*if(old->size>=diff->size)
+      dest_length=old->size;
+    else*/
+      dest_length=diff->size;
+//     unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    if(dest_length==0)
+      return NULL;
+    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
+    while(of<old->size && of<diff->size){
+      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
+      ++of;
+    }
+    if(old->size!=diff->size){ // do we have to fill up ?
+      unsigned char n=0;
+      if(old->size<diff->size){
+        while(of<dest_length){
+          *(dp+of)=n^*(bp+of);
+          of++;
+        }
+      } /*else{
+        while(of<dest_length){
+          *(dp+of)=*(ap+of)^n;
+          of++;
+        }
+      }*/
+    }
+    // should be finished now
+    // FIXME: is it true or false now? (struct has changed, producing warnings)
+    GameState *r = new GameState;
+    r->id = diff->id;
+    r->size = dest_length;
+    r->base_id = old->id;
+    r->diffed = false;
+    r->data = dp;
+    r->complete = true;
+    return r;
+  }
+
+
+
+  GameStateCompressed *GameStateClient::compress_(GameState *a) {
+    if(!a)
+      return NULL;
+    int size = a->size;
+
+    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
+    if(buffer==0)
+      return NULL;
+    unsigned char *dest = new unsigned char[buffer];
+    int retval;
+    retval = compress( dest, &buffer, a->data, (uLong)size );
+
+    switch ( retval ) {
+      case Z_OK: COUT(5) << "G.St.Cl: compress: successfully compressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "G.St.Cl: compress: not enough memory available in gamestate.compress" << std::endl;
+      return NULL;
+      case Z_BUF_ERROR: COUT(2) << "G.St.Cl: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
+      return NULL;
+      case Z_DATA_ERROR: COUT(2) << "G.St.Cl: compress: data corrupted in gamestate.compress" << std::endl;
+      return NULL;
+    }
+
+    GameStateCompressed *compressedGamestate = new GameStateCompressed;
+    compressedGamestate->compsize = buffer;
+    compressedGamestate->normsize = size;
+    compressedGamestate->id = a->id;
+    compressedGamestate->data = dest;
+    compressedGamestate->diffed = a->diffed;
+    compressedGamestate->complete = a->complete;
+    compressedGamestate->base_id = a->base_id;
+    return compressedGamestate;
+  }
+
+
+  GameState *GameStateClient::decompress(GameStateCompressed *a) {
+    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
+    int normsize = a->normsize;
+    int compsize = a->compsize;
+    int bufsize;
+    if(normsize < compsize)
+      bufsize = compsize;
+    else
+      bufsize = normsize;
+//     unsigned char* dest = (unsigned char*)malloc( bufsize );
+    if(bufsize==0)
+      return NULL;
+    unsigned char *dest = new unsigned char[bufsize];
+    int retval;
+    uLongf length=normsize;
+    //std::cout << "gamestateclient" << std::endl;
+    //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
+    retval = uncompress( dest, &length, a->data, (uLong)compsize );
+    //std::cout << "length " << length << std::endl;
+    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 NULL;
+      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
+      case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL;
+    }
+
+    GameState *gamestate = new GameState;
+    gamestate->id = a->id;
+    gamestate->size = normsize;
+    gamestate->data = dest;
+    gamestate->base_id = a->base_id;
+    gamestate->diffed = a->diffed;
+    gamestate->complete = a->complete;
+
+
+    return gamestate;
+  }
+
+  GameState *GameStateClient::decode(GameState *old, GameStateCompressed *diff) {
+    COUT(5) << "using diffed gamestate" << std::endl;
+    GameState *t = decode(diff);
+    if(!t)
+      return NULL;
+    GameState *r = undiff(old, t);
+    delete[] t->data;
+    delete t;
+    return r;
+  }
+
+  GameState *GameStateClient::decode(GameStateCompressed *x) {
+    GameState *t = decompress(x);
+    delete[] x->data;
+    delete x;
+    return t;
+  }
+
+  void GameStateClient::cleanup(){
+    std::map<int, GameState*>::iterator temp, it = gameStateMap.begin();
+    while(it!=gameStateMap.end()){
+      if(it->first>=last_diff_)
+        break;
+      // otherwise delete that stuff
+      delete[] (*it).second->data;
+      delete (*it).second;
+      temp=it++;
+      gameStateMap.erase(temp);
+    }
+    tempGameState_=NULL;
+  }
+
+  void GameStateClient::printGameStateMap(){
+    std::map<int, 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::saveShipCache(){
+    if(myShip_==NULL)
+      myShip_ = orxonox::SpaceShip::getLocalShip();
+    if(myShip_){
+      //      unsigned char *data = new unsigned char[myShip_->getSize()];
+      int size=myShip_->getSize(0x3);
+      if(size==0)
+        return false;
+      unsigned char *data = new unsigned char [size];
+      shipCache_ = myShip_->getData(data, 0x1);
+      return true;
+    }else
+      return false;
+  }
+
+  bool GameStateClient::loadShipCache(){
+    if(myShip_){
+      myShip_->updateData(shipCache_, 0x2);
+      if(shipCache_.data){
+        delete[] shipCache_.data;
+      }
+      return true;
+    }else
+      return false;
+  }
+
+    //##### ADDED FOR TESTING PURPOSE #####
+  GameState* GameStateClient::testDecompress( GameStateCompressed* gc ) {
+    return decompress( gc );
+  }
+
+  GameState* GameStateClient::testUndiff( GameState* g_old, GameState* g_diffed ) {
+    return undiff( g_old, g_diffed );
+  }
+  //##### ADDED FOR TESTING PURPOSE #####
+
+
+}
+
Index: /code/branches/network/src/network/GameStateClient.h
===================================================================
--- /code/branches/network/src/network/GameStateClient.h	(revision 1545)
+++ /code/branches/network/src/network/GameStateClient.h	(revision 1545)
@@ -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:
+ *      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 "PacketTypes.h"
+#include "objects/SpaceShip.h"
+
+
+#define GAMESTATEID_INITIAL -1
+
+namespace network
+{
+  class GameStateClient
+  {
+  public:
+    GameStateClient();
+    ~GameStateClient();
+    
+    void addGameState(GameStateCompressed *gs);
+    int processGameState();
+    GameStateCompressed *popPartialGameState();
+    void cleanup();
+  private:
+    bool pushGameState(GameStateCompressed *compstate);
+    bool loadSnapshot(GameState *state);
+    GameState *getPartialSnapshot();
+    GameState *undiff(GameState *old, GameState *diff);
+    GameStateCompressed *compress_(GameState *a);
+    GameState *decompress(GameStateCompressed *a);
+    GameState *decode(GameState *old, GameStateCompressed *diff);
+    GameState *decode(GameStateCompressed *x);
+    void removeObject(orxonox::Iterator<Synchronisable> &it);
+    void printGameStateMap();
+    bool saveShipCache();
+    bool loadShipCache();
+
+    int           last_diff_;
+    int           last_gamestate_;
+    std::map<int, GameState *> gameStateMap;
+    GameStateCompressed *tempGameState_; // we save the received gamestates here during processQueue
+    orxonox::SpaceShip *myShip_;
+    syncData shipCache_;
+    
+    
+    
+    
+  public:
+    //#### ADDED FOR TESTING PURPOSE ####
+    GameState* testDecompress( GameStateCompressed* gc );
+    GameState* testUndiff( GameState* g_old, GameState* g_diffed );
+    //#### END TESTING PURPOSE ####
+  };
+
+}
+
+#endif /* _GameStateClient_H__ */
Index: /code/branches/network/src/network/GameStateManager.cc
===================================================================
--- /code/branches/network/src/network/GameStateManager.cc	(revision 1545)
+++ /code/branches/network/src/network/GameStateManager.cc	(revision 1545)
@@ -0,0 +1,529 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <assert.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+
+namespace network
+{
+  GameStateManager::GameStateManager(ClientInformation *head) {
+    id_=0;
+    head_=head;
+  }
+
+  GameStateManager::~GameStateManager() {
+  }
+
+  void GameStateManager::update(){
+    cleanup();
+    reference = getSnapshot();
+    COUT(4) << "inserting gamestate: " << reference << std::endl;
+    gameStateMap.insert(std::pair<int, GameState*>(id_, reference));
+    gameStateUsed[id_]=0;
+    printGameStates();
+    return;
+  }
+  
+  void GameStateManager::addGameState(GameStateCompressed *gs, int clientID){
+    if(!gs)
+      return;
+    std::map<int, GameStateCompressed*>::iterator it = gameStateQueue.find(clientID);
+    if(it!=gameStateQueue.end()){
+      // delete obsolete gamestate
+      delete[] it->second->data;
+      delete it->second;
+    }
+    gameStateQueue[clientID] = gs;
+    return;
+  }
+  
+  void GameStateManager::processGameStates(){
+    std::map<int, GameStateCompressed*>::iterator it;
+    // now push only the most recent gamestates we received (ignore obsolete ones)
+    for(it = gameStateQueue.begin(); it!=gameStateQueue.end(); it++){
+      pushGameState(it->second, it->first);
+    }
+    // now clear the queue
+    gameStateQueue.clear();
+  }
+  
+  
+  /**
+   * 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, GameState *>::iterator tempit = gameStateMap.find((*it).first);
+        if( tempit != gameStateMap.end() ){
+          GameState *temp = tempit->second;
+          if(temp){
+            delete[] gameStateMap[(*it).first]->data;
+            delete gameStateMap[(*it).first];
+            gameStateMap.erase((*it).first);
+          }
+        }
+        gameStateUsed.erase(it++);
+        continue;
+      }/*else if(id_-it->first<=KEEP_GAMESTATES){  //as soon as we got a used gamestate break here because we could use newer gamestates in future but only if we do not exceed KEEP_GAMESTATES # of gamestates in cache
+        COUT(4) << "breaking " << std::endl;
+        break;
+      }*/
+      it++;
+    }
+  }
+
+  GameStateCompressed *GameStateManager::popGameState(int clientID) {
+    //why are we searching the same client's gamestate id as we searched in
+    //Server::sendGameState?
+    int gID = head_->findClient(clientID)->getGamestateID();
+    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
+//     COUT(3) << "gamestatemap: " << &gameStateMap << std::endl;
+    //chose wheather the next gamestate is the first or not
+    if(gID != GAMESTATEID_INITIAL){
+      // TODO something with the gamestatemap is wrong
+      GameState *client=NULL;
+      std::map<int, GameState*>::iterator it = gameStateMap.find(gID);
+      if(it!=gameStateMap.end())
+        client = it->second;
+      GameState *server = reference;
+      //COUT(4) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
+      COUT(4) << "client: " << (client!=0 ? client->id : (int)client) << " server: " << server->id << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
+      if(client)
+        return encode(client, server);
+      else
+        return encode(server);
+    } else {
+      COUT(4) << "we got a GAMESTATEID_INITIAL for clientID: " << clientID << std::endl;
+      GameState *server = reference;
+//       ackGameState(clientID, reference->id);
+      return encode(server);
+      // return an undiffed gamestate and set appropriate flags
+    }
+  }
+  
+  bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
+    GameState *ugs = decompress(gs);
+    delete[] gs->data;
+    delete gs;
+    bool result = loadPartialSnapshot(ugs, clientID);
+    delete[] ugs->data;
+    delete ugs;
+    return result;
+  }
+
+  /**
+  * This function goes through the whole list of synchronisables and
+  * saves all the synchronisables to a flat "list".
+  * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
+  */
+  GameState *GameStateManager::getSnapshot()
+  {
+    //std::cout << "begin getSnapshot" << std::endl;
+    //the size of the gamestate
+    int totalsize=0;
+    int memsize=0;
+    //the size of one specific synchronisable
+    int tempsize=0;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it;
+    // struct for return value of Synchronisable::getData()
+    syncData sync;
+
+    GameState *retval=new GameState; //return value
+    retval->id=++id_;
+    COUT(4) << "G.ST.Man: producing gamestate with id: " << retval->id << std::endl;
+    // offset of memory functions
+    int offset=0, size=0;
+    // get total size of gamestate
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      size+=it->getSize(); // size of the actual data of the synchronisable
+      size+=3*sizeof(int); // size of datasize, classID and objectID
+    }
+    //retval->data = (unsigned char*)malloc(size);
+    if(size==0)
+      return NULL;
+    retval->data = new unsigned char[size];
+    if(!retval->data){
+      COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
+      return NULL;
+    }
+    memsize=size;
+    // go through all Synchronisables
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      //get size of the synchronisable
+      tempsize=it->getSize();
+      // add place for data and 3 ints (length,classid,objectid)
+      totalsize+=tempsize+3*sizeof(int);
+      // allocate+tempsize additional space
+      if(totalsize > size){
+        COUT(3) << "G.St.Man: need additional memory" << std::endl;
+//         if(tempsize < 1000){
+//           retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+//           memsize+=1000;
+//         } else {
+//           retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+//           memsize+=tempsize+1000;
+//         }
+//         COUT(5) << "G.St.Man: additional space allocation finished" << std::endl;
+      }
+
+      // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
+      sync=it->getData((retval->data)+offset+3*sizeof(int));
+      memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int));
+      memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int));
+      memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int));
+      // increase data pointer
+      offset+=tempsize+3*sizeof(int);
+    }
+    retval->size=totalsize;
+    //#### bugfix
+    retval->diffed = false;
+    retval->complete = true;
+    //std::cout << "end snapShot" << std::endl;
+    COUT(5) << "G.ST.Man: Gamestate size: " << totalsize << std::endl;
+    COUT(5) << "G.ST.Man: 'estimated' Gamestate size: " << size << std::endl;
+    return retval;
+  }
+
+  bool GameStateManager::loadPartialSnapshot(GameState *state, int clientID){
+    if(!state)
+      return false;
+    unsigned char *data=state->data;
+    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
+    syncData sync;
+    /*ClientInformation *client = head_->findClient(clientID);
+    if(client)
+      if(client->getPartialGamestateID()>state->id){
+        COUT(3) << "we received an obsolete partial gamestate" << std::endl;
+        return false;
+      }
+    else;*/
+        //what should we do now ??
+    // loop as long as we have some data ;)
+    while(data < state->data+state->size){
+      // prepare the syncData struct
+      sync.length = *(int *)data;
+      data+=sizeof(int);
+      sync.objectID = *(int*)data;
+      data+=sizeof(int);
+      sync.classID = *(int*)data;
+      if(sync.classID == 0) // TODO: remove this
+        COUT(3) << "received a classid 0" << std::endl;
+      data+=sizeof(int);
+      sync.data = data;
+      data+=sync.length;
+      COUT(5) << "objectID: " << sync.objectID << " classID: " << sync.classID << std::endl;
+      while(it && it->objectID!=sync.objectID)
+        ++it;
+
+
+      if(!it){
+        // the objectaber ich glaub die  does not exist yet
+        COUT(4) << "loadsnapshot: creating new object " << std::endl;
+        //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
+        orxonox::Identifier* id = ID((unsigned int)sync.classID);
+        if(!id){
+          COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
+          continue;
+        }
+        Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
+        COUT(4) << "loadpartialsnapshot (generating new object): classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
+        no->objectID=sync.objectID;
+        no->classID=sync.classID;
+        it=orxonox::ObjectList<Synchronisable>::end();
+        // update data and create object/entity...
+        if( !no->updateData(sync) )
+          COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
+        if( !no->create() )
+          COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
+      }else{
+        // we have our object
+        COUT(4) << "loadpartialsnapshot: we found the appropriate object" << std::endl;
+        if(checkAccess(clientID, sync.objectID)){
+          if(! it->updateData(sync))
+            COUT(1) << "We couldn't update objectID: " \
+              << sync.objectID << "; classID: " << sync.classID << std::endl;
+        }else
+          COUT(4) << "loadPartialSnapshot: no access to change objectID: " << sync.objectID << std::endl;
+      }
+      ++it;
+    }
+    //client->setPartialGamestateID(state->id);
+    return true;
+  }
+  
+  
+  //##### ADDED FOR TESTING PURPOSE #####
+  GameStateCompressed* GameStateManager::testCompress( GameState* g ) {
+    return compress_( g );
+  }
+
+  GameState* GameStateManager::testDiff( GameState* a, GameState* b ) {
+    return diff( a, b );
+  }
+  //##### END TESTING PURPOSE #####
+
+  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
+    COUT(5) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
+    GameState *r = diff(a,b);
+    GameStateCompressed *c = compress_(r);
+    delete[] r->data;
+    delete r;
+    return c;
+  }
+
+  GameStateCompressed *GameStateManager::encode(GameState *a) {
+    COUT(5) << "G.St.Man: encoding gamestate (compress)" << std::endl;
+    a->base_id=GAMESTATEID_INITIAL;
+    return compress_(a);
+    /*GameStateCompressed *g = new GameStateCompressed;
+    g->base_id = a->base_id;
+    g->id = a->id;
+    g->diffed = a->diffed;
+    g->data = a->data;
+    g->normsize = a->size;
+    g->compsize = a->size;
+    return g;*/
+  }
+
+  GameState *GameStateManager::diff(GameState *alt, GameState *neu) {
+    unsigned char *ap = alt->data, *bp = neu->data;
+    int of=0; // pointers offset
+    int dest_length=0;
+    /*if(alt->size>neu->size)
+      dest_length=alt->size;
+    else*/
+      dest_length=neu->size;
+    if(dest_length==0)
+      return NULL;
+    //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
+    while(of<alt->size && of<neu->size){
+      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
+      ++of;
+    }
+    if(alt->size!=neu->size){ // do we have to fill up ?
+      unsigned char n=0;
+      if(alt->size<neu->size){
+        while(of<dest_length){
+          *(dp+of)=n^*(bp+of);
+          of++;
+        }
+      } /*else{
+        while(of<dest_length){
+          *(dp+of)=*(ap+of)^n;
+          of++;
+        }
+      }*/
+    }
+
+    GameState *r = new GameState;
+    r->id = neu->id;
+    r->size = dest_length;
+    r->diffed = true;
+    r->base_id = alt->id;
+    r->data = dp;
+    r->complete = true;
+    return r;
+  }
+
+  GameStateCompressed *GameStateManager::compress_(GameState *a) {
+    //COUT(4) << "G.St.Man: compressing gamestate" << std::endl;
+
+    //COUT(4) << "G.St.Man: a: id: " << a->id << " base_id: " << a->base_id << " size: " << a->size << " diffed: " << a->diffed << std::endl;
+    int size = a->size;
+
+    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
+    //COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl;
+    //unsigned char* dest = (unsigned char*)malloc( buffer );
+    if(buffer==0)
+      return NULL;
+    unsigned char *dest = new unsigned char[buffer];
+    //COUT(4) << "dest: " << dest << std::endl;
+    int retval;
+    //std::cout << "before ziped " << buffer << std::endl;
+    retval = compress( dest, &buffer, a->data, (uLong)size );
+    //COUT(4) << "bloablabla aft3er compress" << std::endl;
+    //std::cout << "after ziped " << buffer << std::endl;
+
+    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 NULL;
+      case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
+      return NULL;
+      case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl;
+      return NULL;
+    }
+
+    GameStateCompressed *compressedGamestate = new GameStateCompressed;
+    compressedGamestate->compsize = buffer;
+//     std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
+    compressedGamestate->normsize = size;
+//     std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
+    compressedGamestate->id = a->id;
+    compressedGamestate->data = dest;
+    compressedGamestate->diffed = a->diffed;
+    compressedGamestate->complete = a->complete;
+    compressedGamestate->base_id = a->base_id;
+    //COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl;
+    return compressedGamestate;
+  }
+  
+  GameState *GameStateManager::decompress(GameStateCompressed *a) {
+    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
+    int normsize = a->normsize;
+    int compsize = a->compsize;
+    int bufsize;
+    if(normsize < compsize)
+      bufsize = compsize;
+    else
+      bufsize = normsize;
+//     unsigned char* dest = (unsigned char*)malloc( bufsize );
+    if(bufsize==0)
+      return NULL;
+    unsigned char *dest = new unsigned char[bufsize];
+    int retval;
+    uLongf length=normsize;
+    //std::cout << "gamestateclient" << std::endl;
+    //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
+    retval = uncompress( dest, &length, a->data, (uLong)compsize );
+    //std::cout << "length " << length << std::endl;
+    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 NULL;
+      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
+      case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL;
+    }
+
+    GameState *gamestate = new GameState;
+    gamestate->id = a->id;
+    gamestate->size = normsize;
+    gamestate->data = dest;
+    gamestate->base_id = a->base_id;
+    gamestate->diffed = a->diffed;
+    gamestate->complete = a->complete;
+
+
+    return gamestate;
+  }
+  
+
+  void GameStateManager::ackGameState(int clientID, int gamestateID) {
+    ClientInformation *temp = head_->findClient(clientID);
+    if(temp==0)
+      return;
+    int curid = temp->getGamestateID();
+    
+    if(gamestateID == GAMESTATEID_INITIAL){
+      temp->setGameStateID(GAMESTATEID_INITIAL);
+      if(curid!=GAMESTATEID_INITIAL){
+        assert(gameStateUsed.find(curid)!=gameStateUsed.end());
+        --(gameStateUsed.find(curid)->second);
+      }
+      return;
+    }
+    if(curid > gamestateID)
+      // the network packets got messed up 
+      return;
+    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);
+    }
+    /*
+    GameState *old = clientGameState[clientID];
+    deleteUnusedGameState(old);
+    clientGameState[clientID]=idGameState[gamestateID];*/
+  }
+
+  bool GameStateManager::printGameStates() {
+    std::map<int, GameState*>::iterator it;
+    COUT(4) << "gamestates: ";
+    for(it = gameStateMap.begin(); it!=gameStateMap.end(); it++){
+      COUT(4) << (*it).first << ":" << (*it).second << " | ";
+    }
+    COUT(4) << std::endl;
+    return true;
+  }
+  
+  bool GameStateManager::checkAccess(int clientID, int objectID){
+    // currently we only check, wheter the object is the clients spaceship
+//     return head_->findClient(objectID)->getShipID()==objectID;
+    return true; // TODO: change this
+  }
+  
+  void GameStateManager::removeClient(ClientInformation* client){
+    if(!client)
+      return;
+    if(client->getGamestateID()>=0)
+      gameStateUsed[client->getGamestateID()]--;
+    head_->removeClient(client->getID());
+  }
+
+}
Index: /code/branches/network/src/network/GameStateManager.h
===================================================================
--- /code/branches/network/src/network/GameStateManager.h	(revision 1545)
+++ /code/branches/network/src/network/GameStateManager.h	(revision 1545)
@@ -0,0 +1,113 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <map>
+
+#include "PacketTypes.h"
+
+namespace network
+{
+
+#define 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:
+    GameStateManager(ClientInformation *head);
+    ~GameStateManager();
+    
+    void addGameState(GameStateCompressed *gs, int clientID);
+    void processGameStates();
+    
+    void update();
+    GameStateCompressed *popGameState(int clientID);
+    void ackGameState(int clientID, int gamestateID);
+    void removeClient(ClientInformation *client);
+    private:
+    bool pushGameState(GameStateCompressed *gs, int clientID);
+    void cleanup(); // "garbage handler"
+    GameState *getSnapshot();
+    bool loadPartialSnapshot(GameState *state, int clientID);
+    GameStateCompressed *encode(GameState *a, GameState *b);
+    GameStateCompressed *encode(GameState *a);
+    GameState *diff(GameState *alt, GameState *neu);
+    GameStateCompressed *compress_(GameState *a);
+    GameState *decompress(GameStateCompressed *a);
+    bool printGameStates();
+    bool checkAccess(int clientID, int objectID);
+
+    std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
+    std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
+    std::map<int, GameStateCompressed*> gameStateQueue;
+    GameState *reference;
+    ClientInformation *head_;
+    int id_;
+    
+    
+    
+    
+  public:
+    //#### ADDED FOR TESTING PURPOSE ####
+    GameStateCompressed* testCompress( GameState* g );
+    GameState* testDiff( GameState* a, GameState* b );
+  //#### END TESTING PURPOSE ####
+  };
+
+}
+
+#endif /* _GameStateManager_H__ */
Index: /code/branches/network/src/network/Makefile.norm
===================================================================
--- /code/branches/network/src/network/Makefile.norm	(revision 1545)
+++ /code/branches/network/src/network/Makefile.norm	(revision 1545)
@@ -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/network/src/network/Makefile.tardis
===================================================================
--- /code/branches/network/src/network/Makefile.tardis	(revision 1545)
+++ /code/branches/network/src/network/Makefile.tardis	(revision 1545)
@@ -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/network/src/network/Makefile.test
===================================================================
--- /code/branches/network/src/network/Makefile.test	(revision 1545)
+++ /code/branches/network/src/network/Makefile.test	(revision 1545)
@@ -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/network/src/network/NetworkCallback.h
===================================================================
--- /code/branches/network/src/network/NetworkCallback.h	(revision 1545)
+++ /code/branches/network/src/network/NetworkCallback.h	(revision 1545)
@@ -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/network/src/network/NetworkPrereqs.h
===================================================================
--- /code/branches/network/src/network/NetworkPrereqs.h	(revision 1545)
+++ /code/branches/network/src/network/NetworkPrereqs.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+  @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 PacketBuffer;
+  class PacketDecoder;
+  class PacketGenerator;
+  class Server;
+  class ServerFrameListener;
+  class Synchronisable;
+  struct ack;
+  struct chat;
+  struct classid;
+  struct welcome;
+  struct connectRequest;
+  struct ClientList;
+  struct GameState;
+  struct GameStateCompressed;
+  struct keyboard;
+  struct mouse;
+  struct PacketEnvelope;
+  struct QueueItem;
+  struct syncData;
+  struct synchronisableVariable;
+}
+
+#endif /* _NetworkPrereqs_H__ */
Index: /code/branches/network/src/network/PacketBuffer.cc
===================================================================
--- /code/branches/network/src/network/PacketBuffer.cc	(revision 1545)
+++ /code/branches/network/src/network/PacketBuffer.cc	(revision 1545)
@@ -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/network/src/network/PacketBuffer.h
===================================================================
--- /code/branches/network/src/network/PacketBuffer.h	(revision 1545)
+++ /code/branches/network/src/network/PacketBuffer.h	(revision 1545)
@@ -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/network/src/network/PacketDecoder.cc
===================================================================
--- /code/branches/network/src/network/PacketDecoder.cc	(revision 1545)
+++ /code/branches/network/src/network/PacketDecoder.cc	(revision 1545)
@@ -0,0 +1,307 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*
+* Class contains functions to determine and decode incomming packages
+* ->don't read this without the class PacketGenerator, since they belong together
+*
+* Autor: Dumeni Manatschal
+*
+*/
+
+#include "PacketTypes.h"
+#include "PacketManager.h"
+
+#include <iostream>
+
+#include "core/Debug.h"
+
+namespace network
+{
+
+  PacketDecoder::PacketDecoder(){}
+
+  PacketDecoder::~PacketDecoder(){}
+
+  //call this function out of an instance of PacketDecoder
+  //it will determine the type id and call the right decode function
+  bool PacketDecoder::elaborate( ENetPacket* packet, int clientId )
+  {
+    COUT(5) << "PacketDecoder: clientId: " << clientId << std::endl; //control cout, not important, just debugging info
+    int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
+    COUT(5) << "PacketDecoder: packet id: " << id << std::endl;
+    //COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
+
+    if ( packet == NULL ) {
+      COUT(4) << "PacketDecoder: no packets->packetbuffer queue is empty" << std::endl;
+      return false;
+    }
+    switch( id ) {
+    case ACK:
+      acknowledgement( packet, clientId );
+      return true;
+    case COMMAND:
+      return command( packet, clientId );
+    case CHAT:
+      chatMessage( packet, clientId );
+      return true;
+    case GAMESTATE:
+      gstate( packet, clientId );
+      return true;
+    case CLASSID:
+      clid(packet);
+      return true;
+    case WELCOME:
+      return decodeWelcome( packet, clientId );
+    case CONNECT:
+      return decodeConnectRequest( packet, clientId );
+    }
+    return false;
+  }
+
+  bool PacketDecoder::testAndRemoveCRC(ENetPacket *packet){
+    uint32_t submittetcrc;
+    int dataLength = packet->dataLength;
+    // get the submittet crc code
+    memcpy(&submittetcrc, &packet->data[dataLength-sizeof(uint32_t)], sizeof(uint32_t));
+    unsigned char *data = packet->data;
+    uint32_t crc32=calcCRC(data, packet->dataLength-sizeof(uint32_t));
+    // now append the crc to the packet data
+    if(crc32==submittetcrc){
+      dataLength-=sizeof(uint32_t);
+      enet_packet_resize(packet, dataLength);
+      return true;
+    }
+    COUT(3) << "gamestate crc: " << crc32 << std::endl;
+    COUT(3) << "submitted crc: " << submittetcrc << std::endl;
+    return false;
+  }
+
+  // ATTENTION: TODO watch, that arguments we pass over to the processFunction gets deleted in THE PROCESSXXX function
+
+  //following are the decode functions for the data of the packets
+
+  void PacketDecoder::acknowledgement( ENetPacket* packet, int clientId )
+  {
+    ack* a = new ack;
+    *a = *(ack*)(packet->data); //press pattern of ack on new data
+
+
+    COUT(4) << "PacketDecoder: got ack id: " << a->a << std::endl;
+    processAck( a, clientId ); //debug info
+    //clean memory
+    enet_packet_destroy( packet );
+  }
+
+  bool PacketDecoder::command( ENetPacket* packet, int clientId ){
+    int length = *(int*)((unsigned char *)packet->data+sizeof(int));
+    if(length<=0)
+      return false;
+    void *data = (void *)new unsigned char[length];
+    memcpy(data, (void *)(packet->data+2*sizeof(int)), length);
+    enet_packet_destroy( packet );
+    return true;
+  }
+
+  void PacketDecoder::chatMessage( ENetPacket* packet, int clientId )
+  {
+    chat* chatting = new chat;
+    if(packet->dataLength==4)
+      return;
+    chatting->id = (int)*packet->data; //first copy id into new struct
+    //since the chat message is a char*, allocate the memory needed
+    char* reserve = new char[packet->dataLength-4];
+    //copy the transmitted bytestream into the new generated char*,
+    //note the lenght of the message is represented as "packet->dataLength-sizeof( int )"
+    memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-sizeof(int) );
+    //put pointer of chatting struct to the begining of the new generated char*
+    chatting->message = reserve;
+
+    //clean memory
+    enet_packet_destroy( packet );
+
+    processChat( chatting, clientId ); //debug info
+  }
+
+  void PacketDecoder::gstate( ENetPacket* packet, int clientID )
+  {
+//    if(!testAndRemoveCRC(packet)){
+//     COUT(3) << "crc test of gamestate failed - dropping packet" << std::endl;
+//      return;
+//    }
+    GameStateCompressed* currentState = NULL;
+    currentState = new GameStateCompressed;
+    if(currentState == NULL){
+      COUT(3) << "PacketDecoder: could not generate new GameStateCompressed" << std::endl;
+      return;
+    }
+    //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
+    memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) );
+    COUT(5) << "PacketDecoder: received gs id: " << currentState->id << std::endl;
+    //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
+    //position of the data stream, data+2*sizeof( int )
+    memcpy( (void*)&(currentState->compsize), (const void*)(packet->data+2*sizeof( int )), sizeof( int) );
+    //size of uncompressed data
+    memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) );
+    memcpy( (void*)&(currentState->base_id), (const void*)(packet->data+4*sizeof( int )), sizeof( int ) );
+    //since the packetgenerator was changed, due to a new parameter, change this function too
+    memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+5*sizeof(int)), sizeof(bool));
+    memcpy( (void*)&(currentState->complete), (const void*)(packet->data+5*sizeof(int)+sizeof(bool)), sizeof(bool));
+    //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
+    if(currentState->compsize==0)
+    {
+      COUT(2) << "PacketDecoder: compsize is 0" << std::endl;
+    }
+//     currentState->data = (unsigned char*)(malloc( currentState->compsize ));
+    if(currentState->compsize==0)
+      return;
+    currentState->data = new unsigned char[currentState->compsize];
+    if(currentState->data==NULL)
+    {
+      COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl;
+    }
+    //copy the GameStateCompressed data
+    memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + 2*sizeof(bool)), currentState->compsize );
+
+    //clean memory
+    enet_packet_destroy( packet );
+    processGamestate(currentState, clientID);
+  }
+
+  void PacketDecoder::clid( ENetPacket *packet)
+  {
+    classid* cid = new classid;
+    cid->length = ((classid*)(packet->data))->length;
+    cid->id = ((classid *)(packet->data))->id;
+    cid->clid = ((classid *)(packet->data))->clid;
+    if(cid->length==0)
+      return;
+//     cid->message = (const char *)malloc(cid->length);
+    cid->message = new char[cid->length];
+    void *data  = (void *)cid->message;
+    memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
+    COUT(4) << "PacketDecoder: classid: " << cid->clid << ", name: " << cid->message << std::endl;
+    enet_packet_destroy( packet );
+    processClassid(cid);
+  }
+
+
+  bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){
+    welcome *w = new welcome;
+    w->allowed = ((welcome *)(packet->data))->allowed;
+    w->shipID = ((welcome *)(packet->data))->shipID;
+    w->clientID = ((welcome *)(packet->data))->clientID;
+    w->id = ((welcome *)(packet->data))->id;
+    enet_packet_destroy( packet );
+    return processWelcome(w);
+  }
+
+  bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){
+    connectRequest *con = new connectRequest;
+    con->id = ((connectRequest *)(packet->data))->id;
+    enet_packet_destroy( packet );
+    return processConnectRequest(con, clientID );
+  }
+
+
+  // now the data processing functions:
+
+  void PacketDecoder::processChat( chat *data, int clientId)
+  {
+    printChat(data, clientId);
+    delete[] data->message;
+    delete data;
+  }
+
+  void PacketDecoder::processGamestate( GameStateCompressed *state, int clientID )
+  {
+    COUT(3) << "PacketDecoder-process: processing Gamestate" << std::endl;
+    //printGamestate( state );
+//     delete[] state->data;
+//     delete state;
+  }
+
+  void PacketDecoder::processClassid( classid *cid)
+  {
+    printClassid(cid);
+    delete cid;
+    return;
+  }
+
+  void PacketDecoder::processAck( ack *data, int clientID)
+  {
+    printAck(data);
+    delete data;
+    return;
+  }
+
+  bool PacketDecoder::processWelcome( welcome *w ){
+    delete w;
+    return true;
+  }
+
+  bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){
+    COUT(3) << "packetdecoder: processing connectRequest" << std::endl;
+    delete con;
+    return true;
+  }
+
+  //these are some print functions for test stuff
+
+  void PacketDecoder::printAck( ack* data )
+  {
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << data->a << std::endl;
+  }
+
+
+  void PacketDecoder::printChat( chat* data, int clientId )
+  {
+    if(clientId!=CLIENTID_CLIENT)
+    {
+      COUT(5) << "client: " << clientId << std::endl;
+    }
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << data->message << std::endl;
+  }
+
+  void PacketDecoder::printGamestate( GameStateCompressed* data )
+  {
+    COUT(5) << "id of GameStateCompressed:   " << data->id << std::endl;
+    COUT(5) << "size of GameStateCompressed: " << data->compsize << std::endl;
+  }
+
+  void PacketDecoder::printClassid( classid *cid)
+  {
+    COUT(5) << "id of classid:    " << cid->id << std::endl;
+    COUT(5) << "size of classid:  " << cid->length << std::endl;
+    COUT(5) << "ID of classid:    " << cid->clid << std::endl;
+    COUT(5) << "data of classid:  " << cid->message << std::endl;
+  }
+
+}
Index: /code/branches/network/src/network/PacketGenerator.cc
===================================================================
--- /code/branches/network/src/network/PacketGenerator.cc	(revision 1545)
+++ /code/branches/network/src/network/PacketGenerator.cc	(revision 1545)
@@ -0,0 +1,201 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*
+* Class generates packets that can be send by enet
+* ->don't read this without the class PacketDecoder, since they belong together
+*
+* Autor: Dumeni Manatschal
+*
+*/
+
+#include "PacketManager.h"
+#include "PacketTypes.h"
+
+#include <iostream>
+#include <list>
+#include <string>
+#include <cstring>
+
+
+namespace network
+{
+  void calcCRCBit(uint32_t &crc32, int bit){
+    int hbit;
+ 
+    hbit=(crc32 & 0x80000000) ? 1 : 0;
+    if (hbit != bit)
+      crc32=(crc32<<1) ^ NETWORK_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;
+  }
+  
+  PacketGenerator::PacketGenerator() { }
+
+  //following functions create a packet in form of bytestream
+
+  ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
+  {
+    COUT(4) << "PacketGenerator: generating new acknowledgement, id: " << state << std::endl;
+    
+    ENetPacket *packet = enet_packet_create( NULL , sizeof( ack ), reliable );
+    ack* ackreq = (ack *)packet->data;
+    ackreq->id = ACK;
+    ackreq->a = state;
+    //delete ackreq;
+    return packet;
+  }
+  
+  ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE )
+  {
+    if(dataLength==0)
+      return NULL;
+    unsigned char *stream = new unsigned char[dataLength + 2*sizeof(int)];
+    if(!stream)
+      return NULL;
+    packet_id a = COMMAND;
+    memcpy(stream, (void*)&a, sizeof(int));
+    memcpy((unsigned char *)stream+sizeof(int), (void*)&dataLength, sizeof(int));
+    memcpy((unsigned char *)stream+2*sizeof(int), data, dataLength);
+    ENetPacket *packet = enet_packet_create(stream, dataLength+2*sizeof(int), reliable);
+    delete[] stream; // TODO: we could also tell enet not to copy the data, but to use the exisiting memory
+    return packet;
+  }
+
+
+  /*### chat messages packet */
+  ENetPacket* PacketGenerator::chatMessage( const char* message, int reliable )
+  {
+    int* trans = new int[sizeof(int) + strlen(message) + 1];
+    *trans = CHAT;
+    //be carefull here, don't forget to allocate the space before using it ;-)
+    memcpy( &trans[1], (const void*)message, strlen( message ) + 1);
+    ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable );
+    delete[] trans;
+    return packet;
+  }
+
+  /*### gamestate packet */
+  ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
+  {
+    //std::cout << "packetgenerator" << std::endl;
+    //std::cout << "states->normsize " << states->normsize << std::endl;
+    //std::cout << "states->compsize " << states->compsize << std::endl;
+    int gid = GAMESTATE; //first assign the correct enet id
+    int totalLen = 5*sizeof( int ) + 2*sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
+    //std::cout << "totalLen " << totalLen << std::endl;
+    //unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
+    if(totalLen==0)
+      return NULL;
+    ENetPacket *packet = enet_packet_create( NULL , totalLen+sizeof(uint32_t), reliable );
+    //unsigned char *data = new unsigned char[totalLen];
+    unsigned char *data = packet->data;
+    memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
+    memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
+    memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
+    memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
+    memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->base_id), sizeof(int));
+    memcpy( (void*)(data+5*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
+    //place the GameStateCompressed data at the end of the enet datastream
+    memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)&(states->complete), sizeof(bool) );
+    memcpy( (void*)(data+5*sizeof( int ) + 2*sizeof(bool)), (const void*)states->data, states->compsize );
+    
+    //create an enet packet with the generated bytestream
+    COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl;
+    //delete[] data;
+//    if(!addCRC(packet))
+//      COUT(3) << "could not add crc to gamestate packet" << std::endl;
+    return packet;
+  }
+
+  ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable )
+  {
+    //unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
+    if(classname.length()==0)
+      return NULL;
+    unsigned char *data = new unsigned char[3*sizeof(int)+classname.length()+1];
+    std::cout << "PacketGenerator: classid: " << classid << ", name: " << classname << std::endl;
+    *(int *)data = CLASSID;
+    *((int *)data+1) = classname.length()+1;
+    *((int *)data+2) = classid;
+    memcpy( (void *)(data+3*sizeof(int)), classname.c_str(), classname.length()+1);
+    ENetPacket *packet = enet_packet_create( data , 3*sizeof(int)+classname.length()+1, reliable );
+    delete[] data;
+    return packet;
+  }
+  
+  ENetPacket* PacketGenerator::generateWelcome( int clientID,int shipID, bool allowed , int reliable ){
+    welcome *wc = new welcome;
+    wc->id = WELCOME;
+    wc->clientID = clientID;
+    wc->shipID = shipID;
+    wc->allowed = true;
+    ENetPacket *packet = enet_packet_create( wc, sizeof(welcome), reliable);
+    delete wc;
+    return packet;
+  }
+  
+  ENetPacket* PacketGenerator::generateConnectRequest( int reliable ){
+    connectRequest *con = new connectRequest;
+    con->id=CONNECT;
+    ENetPacket *packet = enet_packet_create( con, sizeof(connectRequest), reliable);
+    delete con;
+    return packet;
+  }
+  
+  
+  bool PacketGenerator::addCRC( ENetPacket *packet){
+    unsigned char *data = packet->data;
+    uint32_t crc32=calcCRC(data, packet->dataLength-sizeof(uint32_t));
+    // now append the crc to the packet data
+    int oldlength = packet->dataLength-sizeof(uint32_t);
+    //if(enet_packet_resize(packet, packet->dataLength+sizeof(uint32_t))==0){
+      memcpy(&packet->data[oldlength], &crc32, sizeof(uint32_t));
+      return true;
+    //}else{
+     // COUT(3) << "could not add crc to gamestate" << std::endl;
+     // return false;
+    //}
+  }
+
+}
Index: /code/branches/network/src/network/PacketManager.h
===================================================================
--- /code/branches/network/src/network/PacketManager.h	(revision 1545)
+++ /code/branches/network/src/network/PacketManager.h	(revision 1545)
@@ -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:
+ *      Dumeni Manatschal, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PacketManager_H__
+#define _PacketManager_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <enet/enet.h>
+
+#include "core/CoreIncludes.h"
+
+#define CLIENTID_CLIENT -1
+#define NETWORK_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */
+
+//enum netowk generally used to set the type ID of a packet
+namespace network
+{
+  /*
+  * class to generate packets
+  *
+  * @autor: Dumeni Manatschal
+  *
+  */
+  //void calcCRC(uint32_t &crc32, int bit);
+  uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+  
+  class PacketGenerator
+  {
+  public:
+    PacketGenerator();
+    //call one of this functions out of an instance of PacketGenerator to create a packet
+    ENetPacket* acknowledgement( int state, int reliable = 0 ); // we do not want reliability
+    ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* gstate( GameStateCompressed *states, int reliable = 0 ); // we do not want reliability of gamestates
+    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* generateWelcome( int clientID,int shipID, bool allowed, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* generateConnectRequest( int reliable = ENET_PACKET_FLAG_RELIABLE );
+  private:
+    bool addCRC( ENetPacket *packet);
+  };
+
+  /*
+  * class used to decode incoming packets
+  *
+  * @autor: Dumeni Manatschal
+  *
+  */
+  class _NetworkExport PacketDecoder
+  {
+  public:
+    PacketDecoder();
+    virtual ~PacketDecoder();
+    //call this function to decode, it calls the right decoding function below
+    bool elaborate( ENetPacket* packet, int clientId );
+  protected:
+
+    virtual void processChat( chat *data, int clientId);
+
+
+  private:
+    bool testAndRemoveCRC(ENetPacket *packet);
+
+
+    void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    bool command( ENetPacket* packet, int clientId );
+    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    void gstate( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
+    void clid( ENetPacket *packet);
+    bool decodeWelcome( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
+    bool decodeConnectRequest( ENetPacket *packet, int clientID = CLIENTID_CLIENT );
+
+    //process data
+    //two functions are note yet implemented!
+    virtual void processGamestate(GameStateCompressed *state, int clientID);
+    virtual void processAck( ack *data, int clientID);
+    virtual void processClassid( classid *cid);
+    virtual bool processWelcome( welcome *w );
+    virtual bool processConnectRequest( connectRequest *con, int clientID );
+    //virtual void processAck( ack *data);
+
+    //print functions
+    void printAck( ack* data );
+    void printChat( chat* data, int clientId );
+    void printGamestate( GameStateCompressed *data );
+    void printClassid( classid *cid);
+  };
+}
+
+#endif /* _PacketManager_H__ */
Index: /code/branches/network/src/network/PacketTypes.h
===================================================================
--- /code/branches/network/src/network/PacketTypes.h	(revision 1545)
+++ /code/branches/network/src/network/PacketTypes.h	(revision 1545)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: PacketTypes
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _PacketTypes_H__
+#define _PacketTypes_H__
+
+#include "NetworkPrereqs.h"
+
+namespace network
+{
+  enum packet_id {
+    ACK,
+    COMMAND,
+    CHAT,
+    GAMESTATE ,
+    CLASSID,
+    WELCOME,
+    CONNECT,
+  };
+
+
+  /**
+  * This struct defines a gamestate:
+  * size: total size of the data in *data
+  * data: pointer to the data allocated in the memory
+  */
+  struct GameState{
+    int id;
+    int size;                       //!< total size of data
+    // new ---- change functions
+    int base_id;                    // if gamestate is diffed this is the id of the old gamestate (base)
+    bool diffed;
+    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
+    unsigned char *data;            //!< pointer to data
+  };
+
+  /**
+  * this struct defines a gamestate:
+  * compsize is the size of the compressed data
+  * normsize is the size of the uncompressed data
+  * data are the gamestates
+  */
+  struct GameStateCompressed{
+    int id;
+    int compsize;                   //!< size of compressed data
+    int normsize;                   //!< size of uncompressed data
+    // new ----- change functions
+    int base_id;                  // if gamestate is diffed this is the id of the old gamestate (base)
+    bool diffed;
+    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
+    unsigned char *data;            //!< gamestate data
+  };
+
+  struct classid{
+    int id;
+    int length;
+    int clid;
+    const char *message;
+  };
+
+
+  struct ack {
+    int id;
+    int a;
+  };
+
+  //only in this class, not PacketGenerator, used as pattern to put incoming
+  //bytes inside
+  struct chat {
+    int id;
+    const char* message;
+  };
+
+  struct welcome {
+    int id;
+    int clientID;
+    int shipID;
+    bool allowed;
+  };
+  
+  struct connectRequest{
+    int id;
+  };
+}
+
+#endif /* _PacketTypes_H__ */
Index: /code/branches/network/src/network/Server.cc
===================================================================
--- /code/branches/network/src/network/Server.cc	(revision 1545)
+++ /code/branches/network/src/network/Server.cc	(revision 1545)
@@ -0,0 +1,424 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "ConnectionManager.h"
+#include "PacketTypes.h"
+#include "GameStateManager.h"
+#include "ClientInformation.h"
+//#include "NetworkFrameListener.h"
+#include "util/Sleep.h"
+#include "objects/SpaceShip.h"
+#include "core/ConsoleCommand.h"
+
+namespace network
+{
+  #define MAX_FAILURES 20;
+  #define NETWORK_FREQUENCY 30
+  
+  Server *Server::instance_=0;
+  
+  Server *Server::createSingleton(){
+    if(!instance_)
+      instance_ = new Server();
+    return instance_;
+  }
+  Server *Server::createSingleton(int port){
+    if(!instance_)
+      instance_ = new Server(port);
+    return instance_;
+  }
+  Server *Server::createSingleton(int port, std::string bindAddress){
+    if(!instance_)
+      instance_ = new Server(port, bindAddress);
+    return instance_;
+  }
+  Server *Server::createSingleton(int port, const char *bindAddress){
+    if(!instance_)
+      instance_ = new Server(port, bindAddress);
+    return instance_;
+  }
+  
+  Server *Server::getSingleton(){
+    return instance_;
+  }
+  
+  
+  /**
+  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
+  *
+  */
+  Server::Server() {
+    timeSinceLastUpdate_=0;
+    packet_gen = PacketGenerator();
+    clients = new ClientInformation(true);
+    connection = new ConnectionManager(clients);
+    gamestates = new GameStateManager(clients);
+  }
+  
+  Server::Server(int port){
+    timeSinceLastUpdate_=0;
+    packet_gen = PacketGenerator();
+    clients = new ClientInformation(true);
+    connection = new ConnectionManager(clients, port);
+    gamestates = new GameStateManager(clients);
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, std::string bindAddress) {
+    timeSinceLastUpdate_=0;
+    packet_gen = PacketGenerator();
+    clients = new ClientInformation();
+    connection = new ConnectionManager(port, bindAddress, clients);
+    gamestates = new GameStateManager(clients);
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, const char *bindAddress) {
+    timeSinceLastUpdate_=0;
+    packet_gen = PacketGenerator();
+    clients = new ClientInformation();
+    connection = new ConnectionManager(port, bindAddress, clients);
+    gamestates = new GameStateManager(clients);
+  }
+
+  /**
+  * 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;
+  }
+
+  /**
+  * This function sends out a message to all clients
+  * @param msg message
+  * @return true/false
+  */
+  bool Server::sendChat(std::string msg) {
+    return sendChat(msg.c_str());
+  }
+
+  /**
+  * 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_-=(1./NETWORK_FREQUENCY);
+      gamestates->processGameStates();
+      updateGamestate();
+    }
+//     usleep(5000); // TODO remove
+    return;
+  }
+
+  /**
+  * processes all the packets waiting in the queue
+  */
+  void Server::processQueue() {
+    ENetEvent *event;
+    int clientID=-1;
+    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(clients->findClient(&event->peer->address))
+          disconnectClient(event);
+        break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        if(clients->findClient(&event->peer->address)){
+          clientID = clients->findClient(&event->peer->address)->getID();
+          if( !elaborate(event->packet, clientID) ) 
+            COUT(3) << "Server: could not elaborate" << std::endl;
+        }
+        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;
+  }
+
+  /**
+  * sends the gamestate
+  */
+  bool Server::sendGameState() {
+    COUT(5) << "Server: starting function sendGameState" << std::endl;
+    ClientInformation *temp = clients;
+    bool added=false;
+    while(temp != NULL){
+      if(temp->getHead()){
+        temp=temp->next();
+        //think this works without continue
+        continue;
+      }
+      if( !(temp->getSynched()) ){
+        COUT(5) << "Server: not sending gamestate" << std::endl;
+        temp=temp->next();
+        //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;
+      GameStateCompressed *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;
+      ENetPacket *packet = packet_gen.gstate(gs);
+      if(!packet)
+	continue;
+      if ( !(connection->addPacket(packet, cid)) ){
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
+        temp->addFailure();
+        /*if(temp->getFailures() > 0 )
+          disconnectClient(temp);*/
+      //std::cout << "added gamestate" << std::endl;
+      }else
+        temp->resetFailures();
+      added=true;
+      temp=temp->next();
+      // now delete gamestate
+      delete[] gs->data;
+      delete gs;
+    }
+    /*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::processAck( ack *data, int clientID) {
+    COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
+    gamestates->ackGameState(clientID, data->a);
+    delete data;
+  }
+  
+  bool Server::processConnectRequest( connectRequest *con, int clientID ){
+    //(COUT(3) << "processing connectRequest " << std::endl;
+    //connection->addPacket(packet_gen.gstate(gamestates->popGameState(clientID)) , clientID);
+    //createClient(clientID);
+    delete con;
+    return true;
+  }
+  
+  void Server::processGamestate( GameStateCompressed *data, int clientID){
+    COUT(4) << "processing partial gamestate from client " << clientID << std::endl;
+    gamestates->addGameState(data, clientID);
+        /*COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
+    else
+      if(clients->findClient(clientID))
+        clients->findClient(clientID)->resetFailures();*/
+  }
+  
+  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 = clients->insertBack(new ClientInformation);
+    if(!temp){
+      COUT(2) << "Server: could not add client" << std::endl;
+      return false;
+    }
+    if(temp->prev()->getHead()) { //not good if you use anything else than insertBack
+      temp->prev()->setID(0); //bugfix: not necessary but usefull
+      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 = clients->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;
+    connection->sendWelcome(temp->getID(), temp->getShipID(), true);
+    return true;
+  }
+  
+  bool Server::createShip(ClientInformation *client){
+    if(!client)
+      return false;
+    orxonox::Identifier* id = ID("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->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("cam_"+client->getID());
+    no->classID = id->getNetworkID();
+    no->create();
+    
+    client->setShipID(no->objectID);
+    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::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();
+    ClientInformation *client = clients->findClient(&event->peer->address);
+    if(!client)
+      return false;
+    while(it){
+      if(it->objectID!=client->getShipID()){
+        ++it;
+        continue;
+      }
+      orxonox::Iterator<orxonox::SpaceShip> temp=it;
+      ++it;
+      delete  *temp;
+      return clients->removeClient(event->peer);
+    }
+    return false;
+  }
+
+  void Server::disconnectClient(int clientID){
+    ClientInformation *client = clients->findClient(clientID);
+    if(client)
+      disconnectClient(client);
+  }
+  void Server::disconnectClient( ClientInformation *client){
+    connection->disconnectClient(client);
+    gamestates->removeClient(client);
+  }
+  
+}
Index: /code/branches/network/src/network/Server.h
===================================================================
--- /code/branches/network/src/network/Server.h	(revision 1545)
+++ /code/branches/network/src/network/Server.h	(revision 1545)
@@ -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:
+ *      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 "PacketManager.h"
+
+
+
+namespace network
+{
+  #define 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 PacketDecoder{
+  public:
+    static Server *createSingleton();
+    static Server *createSingleton(int port);
+    static Server *createSingleton(int port, std::string bindAddress);
+    static Server *createSingleton(int port, const char *bindAddress);
+    
+    static Server *getSingleton();
+    
+    void open();
+    void close();
+    bool sendChat(std::string msg);
+    bool sendChat(const char *msg);
+    void tick(float time);
+  protected:
+    void processQueue();
+    void updateGamestate();
+  private:
+    Server();
+    Server(int port);
+    Server(int port, std::string bindAddress);
+    Server(int port, const char *bindAddress);
+    
+    static Server *instance_;
+    
+    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 sendGameState();
+    void processAck( ack *data, int clientID);
+    bool processConnectRequest( connectRequest *con, int clientID );
+    void processGamestate( GameStateCompressed *data, int clientID);
+    void processChat( chat *data, int clientId);
+    ConnectionManager *connection;
+    GameStateManager *gamestates;
+    PacketGenerator packet_gen;
+
+    ClientInformation *clients;
+    float timeSinceLastUpdate_;
+  };
+
+
+
+
+}
+
+#endif /* _Server_H__ */
Index: /code/branches/network/src/network/Synchronisable.cc
===================================================================
--- /code/branches/network/src/network/Synchronisable.cc	(revision 1545)
+++ /code/branches/network/src/network/Synchronisable.cc	(revision 1545)
@@ -0,0 +1,289 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/CoreIncludes.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;
+    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;
+  }
+
+  /**
+  * 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);
+  }
+
+  /**
+  * note: only use this function for debug use, because it's inefficient (in order to produce a gamestate, you have to copy the whole data again to another memory location after this process)
+  * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
+  * 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
+  */
+  // syncData Synchronisable::getData(){
+  //   std::list<synchronisableVariable>::iterator i;
+  //   int totalsize=0;
+  //   //figure out size of data to be allocated
+  //   for(i=syncList->begin(); i!=syncList->end(); i++){
+  //     // increase size (size of variable and size of size of variable ;)
+  //     if(i->type == STRING)
+  //       totalsize+=sizeof(int)+((std::string *)i->var)->length()+1;
+  //     else
+  //       totalsize+=sizeof(int)+i->size;
+  //   }
+  //   syncData retVal;
+  //   retVal.objectID=this->objectID;
+  //   retVal.classID=this->classID;
+  //   retVal.length=totalsize;
+  //   // allocate memory
+  //   retVal.data = (unsigned char *)malloc(totalsize);
+  //   // copy to location
+  //   //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP
+  //   int n=0;
+  //   for(i=syncList->begin(); n<totalsize && i!=syncList->end(); i++){
+  //     std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int));
+  //     n+=sizeof(int);
+  //     switch(i->type){
+  //     case STRING:
+  //       std::memcpy(retVal.data+n, (const void *)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1);
+  //       n+=((std::string *)i->var)->length()+1;
+  //       break;
+  //     case DATA:
+  //       std::memcpy(retVal.data+n, ((const void*)i->var), i->size);
+  //       n+=i->size;
+  //       break;
+  //     }
+  //   }
+  //   return retVal;
+  // }
+  /**
+  * 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
+  */
+  syncData Synchronisable::getData(unsigned char *mem, int mode){
+    //std::cout << "inside getData" << std::endl;
+    if(mode==0x0)
+      mode=state_;
+    if(classID==0)
+      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+    this->classID=this->getIdentifier()->getNetworkID();
+    std::list<synchronisableVariable *>::iterator i;
+    syncData retVal;
+    retVal.objectID=this->objectID;
+    retVal.classID=this->classID;
+    retVal.length=getSize();
+    COUT(5) << "Synchronisable getting data from objectID: " << retVal.objectID << " classID: " << retVal.classID << " length: " << retVal.length << std::endl;
+    retVal.data=mem;
+    // copy to location
+    int n=0; //offset
+    for(i=syncList->begin(); n<datasize && 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:
+        std::memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size);
+        n+=(*i)->size;
+        break;
+      case STRING:
+        memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) );
+        n+=sizeof(int);
+        const char *data = ( ( *(std::string *) (*i)->var).c_str());
+        std::memcpy( retVal.data+n, (void*)data, (*i)->size);
+        COUT(5) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
+        n+=(*i)->size;
+        break;
+      }
+    }
+    return retVal;
+  }
+
+  /**
+  * 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(syncData vars, int mode){
+    if(mode==0x0)
+      mode=state_;
+    unsigned char *data=vars.data;
+    std::list<synchronisableVariable *>::iterator i;
+    if(syncList->empty()){
+      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
+      return false;
+    }
+    COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl;
+    for(i=syncList->begin(); i!=syncList->end(); 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 *)data, (*i)->size)!=0)
+            callback=true;
+        memcpy((void*)(*i)->var, data, (*i)->size);
+        data+=(*i)->size;
+        break;
+      case STRING:
+        (*i)->size = *(int *)data;
+        COUT(5) << "string size: " << (*i)->size << std::endl;
+        data+=sizeof(int);
+        if((*i)->callback) // check whether this string changed
+          if( *(std::string *)((*i)->var) != std::string((char *)data) )
+            callback=true;
+        *((std::string *)((*i)->var)) = std::string((const char*)data);
+        COUT(5) << "synchronisable: char: " << (const char*)data << " string: " << std::string((const char*)data) << std::endl;
+        data += (*i)->size;
+        break;
+      }
+      // call the callback function, if defined
+      if(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(int mode){
+    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;
+  }
+  
+  void Synchronisable::setBacksync(bool sync){
+    backsync_=sync;
+  }
+
+  bool Synchronisable::getBacksync(){
+    return backsync_;
+  }
+  
+}
Index: /code/branches/network/src/network/Synchronisable.h
===================================================================
--- /code/branches/network/src/network/Synchronisable.h	(revision 1545)
+++ /code/branches/network/src/network/Synchronisable.h	(revision 1545)
@@ -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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Synchronisable_H__
+#define _Synchronisable_H__
+
+#include "NetworkPrereqs.h"
+
+#include <list>
+#include "core/OrxonoxClass.h"
+#include "NetworkCallback.h"
+
+namespace network
+{
+  enum variableType{
+    DATA,
+    STRING,
+  };
+
+  struct syncData{
+    int length;
+    int objectID;
+    int classID;
+    unsigned char *data;
+  };
+
+  typedef struct synchronisableVariable{
+    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();
+    int objectID;
+    int classID;
+
+    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
+    //  syncData getData();
+    syncData getData(unsigned char *mem, int mode=0x0);
+    int getSize(int mode=0x0);
+    bool updateData(syncData vars, int mode=0x0);
+    void setBacksync(bool sync);
+    bool getBacksync();
+    virtual void registerAllVariables()=0;
+    virtual bool create();
+    static void setClient(bool b);
+  protected:
+    Synchronisable();
+  private:
+    /*  bool removeObject(Iterator<Synchronisable> it);*/
+
+    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)
+  };
+}
+
+#endif /* _Synchronisable_H__ */
Index: /code/branches/network/src/network/TODO
===================================================================
--- /code/branches/network/src/network/TODO	(revision 1545)
+++ /code/branches/network/src/network/TODO	(revision 1545)
@@ -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/network/src/network/diffTest.cc
===================================================================
--- /code/branches/network/src/network/diffTest.cc	(revision 1545)
+++ /code/branches/network/src/network/diffTest.cc	(revision 1545)
@@ -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/network/src/network/dummyclient.cc
===================================================================
--- /code/branches/network/src/network/dummyclient.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyclient.cc	(revision 1545)
@@ -0,0 +1,124 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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:
+ *      ...
+ *
+ */
+
+//o
+// Dummy client to test ConnectionManager and PacketBuffer classes
+//
+// Author: Oliver Scheuss
+
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+
+#include "util/Sleep.h"
+#include "PacketManager.h"
+#include "PacketTypes.h"
+
+using namespace std;
+
+int main(){
+  ENetHost * client;
+  ENetAddress address;
+  ENetEvent event;
+  ENetPeer *peer;
+  network::PacketGenerator pck;
+
+  enet_initialize();
+  atexit(enet_deinitialize);
+
+  cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << endl;
+  string str;
+  getline(cin, str);
+  cout << "You entered: " << str << endl;
+  if(str.compare("")==0)
+    str="127.0.0.1";
+
+  enet_address_set_host(&address, str.c_str());
+  address.port = 55556;
+
+  // create client object
+  client = enet_host_create(NULL, 2, 0, 0);
+
+  if(client==NULL){
+    fprintf(stderr, "An error occured");
+    exit(EXIT_FAILURE);
+  }
+  // connect peer
+  peer = enet_host_connect(client, &address, 2);
+  if(peer==NULL){
+    fprintf(stderr, "Peer establishing error");
+    exit(EXIT_FAILURE);
+  }
+  // wait 5 seconds for the connection attempt to succeed
+  if(enet_host_service(client, &event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT){
+    cout << "Connection to " << str << " succeeded." << endl;
+    //puts("Connection to localhost:5555 succeeded.");
+  }else{
+    enet_peer_reset(peer);
+    cout << "Connection to " << str << " failed." << endl;
+    //puts("Connection to localhost:5555 failed.");
+    exit(EXIT_FAILURE);
+  }
+
+  for(int i=0; i<10; i++){
+    // weihnachtsmann bringt packete
+    //ENetPacket *packet = enet_packet_create ("packet1234", strlen("packet1234") + 1, ENET_PACKET_FLAG_RELIABLE);
+    // extend the packet and append the string foo to it
+    // send packet to peer on channel id 0
+    enet_peer_send(peer, 1, pck.chatMessage("test2"));
+    // keep the timeout very small for low delay
+    if(enet_host_service(client, &event, 1)==0){
+      cout << "successfully sent: " << event.type << endl;
+    }else{
+      cout << "failed sending" << endl;
+    }
+    usleep(1000000);
+  }
+
+  // now disconnect
+  //   enet_peer_disconnect (peer);
+  enet_peer_disconnect (peer, 0);
+  // 3 seconds timeout
+  while(enet_host_service(client, &event, 3000) > 0){
+    switch (event.type)
+    {
+    case ENET_EVENT_TYPE_RECEIVE:
+      enet_packet_destroy(event.packet);
+      break;
+    case ENET_EVENT_TYPE_DISCONNECT:
+      puts("Disconnection succeeded.");
+      return 0;
+    }
+  }
+  // if disconnect failed
+  enet_peer_reset(peer);
+
+
+
+  return 0;
+}
Index: /code/branches/network/src/network/dummyclient2.cc
===================================================================
--- /code/branches/network/src/network/dummyclient2.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyclient2.cc	(revision 1545)
@@ -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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// Dummy client to test ConnectionManager, PacketBuffer, ClientConnection and other classes
+//
+// Author: Oliver Scheuss
+
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+
+#include "util/Sleep.h"
+#include "PacketManager.h"
+#include "PacketTypes.h"
+#include "ClientConnection.h"
+
+using namespace network;
+
+int main(){
+  network::PacketGenerator pck;
+
+  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
+  std::string str;
+  std::getline(std::cin, str);
+  std::cout << "You entered: " << str << std::endl;
+  if(str.compare("")==0)
+    str="127.0.0.1";
+
+  ClientConnection client = ClientConnection(55556, str);
+
+  client.createConnection();
+
+  if(client.waitEstablished(10000))
+    std::cout << "Connection established" << std::endl;
+  else
+    std::cout << "Connection failed" << std::endl;
+
+  ENetPacket *packet;  //FIXME: unused var!
+  ENetEvent event;
+
+
+
+  for(int i=0; i<10; i++){
+    // weihnachtsmann bringt packete
+    // extend the packet and append the string foo to it
+    // send packet to peer on channel id 0
+    client.addPacket(pck.chatMessage("test"));
+    // keep the timeout very small for low delay
+    if(client.sendPackets(&event)){
+      std::cout << "successfully sent: " << event.type << std::endl;
+    }else{
+      std::cout << "failed sending" << std::endl;
+    }
+    //    usleep(1000000);
+  }
+  usleep(1000000);
+  // now disconnect
+  if(client.closeConnection())
+    std::cout << "Connection successfully closed" << std::endl;
+  else
+    std::cout << "Connection closing failed" << std::endl;
+
+  // 3 seconds timeout
+  return 0;
+}
+
Index: /code/branches/network/src/network/dummyclient3.cc
===================================================================
--- /code/branches/network/src/network/dummyclient3.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyclient3.cc	(revision 1545)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Client.h"
+
+#include <iostream>
+#include <string>
+
+#include "util/Sleep.h"
+#include "PacketManager.h"
+#include "PacketTypes.h"
+
+using namespace network;
+
+void sender(){
+
+  network::PacketGenerator pck;
+  const int PORT = 55556;
+  COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
+  std::string str;
+  std::getline(std::cin, str);
+  COUT(3) << "You entered: " << str << std::endl;
+  if(str.compare("")==0)
+    str="127.0.0.1";
+
+  Client client( str, PORT );
+  if ( client.establishConnection() )
+  {
+    COUT(3) << "connection established" << std::endl;
+  }
+  else
+  {
+    COUT(0) << "problems establishing connection" << std::endl;
+  }
+  char message[10000];
+  char signs[] = "abcdefghijklmnopqrstuvwxy";
+  while (true) {
+    client.tick(0);
+
+    std::cout << "your message2: ";
+    for ( int i=0; i<9999; i++ ) {
+      message[i] = signs[0];
+    }
+    message[9999] = 'z';
+    std::string str( message );
+    client.sendChat( str );
+    std::cout << str << std::endl;
+    std::cin.get(); std::cin.get();
+  }
+
+
+
+}
+
+void listener(){
+
+  const int PORT = 55556;
+  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
+  std::string str;
+  std::getline(std::cin, str);
+  std::cout << "You entered: " << str << std::endl;
+  if(str.compare("")==0)
+    str="127.0.0.1";
+
+  Client client( str, PORT );
+  if ( client.establishConnection() )
+    std::cout << "connection established" << std::endl;
+  else std::cout << "problems establishing connection" << std::endl;
+
+  while (true) {
+    client.tick(0);
+    usleep(100);
+  }
+
+
+
+}
+
+
+int main(int argc, char **argv[]){
+  std::string in;
+  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
+  std::getline(std::cin, in);
+  if(in.compare("l")==0)
+    listener();
+  else if(in.compare("s")==0)
+    sender();
+  else
+    std::cout << "wrong answer" << std::endl;
+}
Index: /code/branches/network/src/network/dummyclient4.cc
===================================================================
--- /code/branches/network/src/network/dummyclient4.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyclient4.cc	(revision 1545)
@@ -0,0 +1,29 @@
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+#include <network/PacketManager.h>
+#include <network/PacketTypes.h>
+#include <network/Client.h>
+#include "core/Tickable.h"
+#include "core/BaseObject.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+
+int main() {
+  std::cout << "dummyclient4" << std::endl;
+  network::Client* client;
+  client = network::Client::createSingleton( "127.0.0.1", 55556 );
+  if(client->establishConnection())
+    std::cout << "established connection" << std::endl;
+  else{
+    std::cout << "could not establish connection" << std::endl;
+    return -1;
+  }
+  if(client->closeConnection())
+    std::cout << "closed connection" << std::endl;
+  else
+    std::cout << "could not close connection" << std::endl;
+}
+
+
Index: /code/branches/network/src/network/dummyserver.cc
===================================================================
--- /code/branches/network/src/network/dummyserver.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyserver.cc	(revision 1545)
@@ -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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// Dummy server to test ConnectionManager and PacketBuffer classes
+//
+// Author: Oliver Scheuss
+
+#include <iostream>
+#include <enet/enet.h>
+
+#include "util/Sleep.h"
+#include "ConnectionManager.h"
+#include "PacketManager.h"
+#include "PacketTypes.h"
+#include "ClientInformation.h"
+
+using namespace network;
+
+int main(){
+  bool quit=false;
+  ENetPacket *packet;
+  ClientInformation clients;
+  ConnectionManager server = ConnectionManager(&clients);
+  server.createListener();
+
+  PacketDecoder dec;
+
+  while(!quit){
+    if(server.queueEmpty())
+      // Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
+      usleep(1);
+    else{
+      ENetAddress addr;
+      packet=server.getPacket(addr);
+      if(packet==NULL){
+        // there was some error
+        //std::cout << "null pointer" << std::endl;
+        quit=true;
+      }
+      else{
+        //std::cout << "We received: " << packet->data << std::endl;
+        dec.elaborate(packet, 1);
+      }
+    }
+  }
+  server.quitListener();
+  return 0;
+}
Index: /code/branches/network/src/network/dummyserver3.cc
===================================================================
--- /code/branches/network/src/network/dummyserver3.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyserver3.cc	(revision 1545)
@@ -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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Server.h"
+
+#include <iostream>
+
+#include "util/Sleep.h"
+#include "PacketManager.h"
+#include "PacketTypes.h"
+
+namespace network
+{
+
+  class dummyserver3 : public Server
+  {
+  public:
+    dummyserver3();
+    ~dummyserver3();
+    void loop();
+  private:
+    void tick();
+    void processChat( chat *data, int clientId);
+
+
+  };
+
+  dummyserver3::dummyserver3(){
+  }
+  dummyserver3::~dummyserver3(){
+  }
+
+  void dummyserver3::loop(){
+    open();
+    while(true){
+      tick();
+      usleep(100);
+    }
+  }
+
+  void dummyserver3::processChat( chat *data, int clientId){
+    std::cout << "Client " << clientId << " sent: " << data->message << std::endl;
+    sendMSG(data->message);
+  }
+
+  void dummyserver3::tick(){
+    processQueue();
+  }
+
+}
+
+int main(int argc, char **argv[]){
+  network::dummyserver3 server;
+  server.loop();
+  return 0;
+}
Index: /code/branches/network/src/network/dummyserver4.cc
===================================================================
--- /code/branches/network/src/network/dummyserver4.cc	(revision 1545)
+++ /code/branches/network/src/network/dummyserver4.cc	(revision 1545)
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+#include <network/PacketManager.h>
+#include <network/PacketTypes.h>
+#include <network/Server.h>
+#include "core/Tickable.h"
+#include "core/BaseObject.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+#include "util/Sleep.h"
+
+int main() {
+  network::Server *server = new network::Server();
+  server->open();
+  while(true){
+    usleep( 1000 );
+  }
+  server->close();
+  return 0;
+}
Index: /code/branches/network/src/ois/CMakeLists.txt
===================================================================
--- /code/branches/network/src/ois/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/ois/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,47 @@
+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 SHARED ${OIS_SRC_FILES} )
+
+IF(WIN32)
+  LINK_DIRECTORIES(${DirectX_LIB_DIR})
+  TARGET_LINK_LIBRARIES( ois
+    dxguid
+    dinput8
+  )
+ENDIF(WIN32)
+
Index: /code/branches/network/src/ois/OIS.h
===================================================================
--- /code/branches/network/src/ois/OIS.h	(revision 1545)
+++ /code/branches/network/src/ois/OIS.h	(revision 1545)
@@ -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/network/src/ois/OISConfig.h
===================================================================
--- /code/branches/network/src/ois/OISConfig.h	(revision 1545)
+++ /code/branches/network/src/ois/OISConfig.h	(revision 1545)
@@ -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/network/src/ois/OISEffect.cpp
===================================================================
--- /code/branches/network/src/ois/OISEffect.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISEffect.cpp	(revision 1545)
@@ -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/network/src/ois/OISEffect.h
===================================================================
--- /code/branches/network/src/ois/OISEffect.h	(revision 1545)
+++ /code/branches/network/src/ois/OISEffect.h	(revision 1545)
@@ -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/network/src/ois/OISEvents.h
===================================================================
--- /code/branches/network/src/ois/OISEvents.h	(revision 1545)
+++ /code/branches/network/src/ois/OISEvents.h	(revision 1545)
@@ -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/network/src/ois/OISException.cpp
===================================================================
--- /code/branches/network/src/ois/OISException.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISException.cpp	(revision 1545)
@@ -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/network/src/ois/OISException.h
===================================================================
--- /code/branches/network/src/ois/OISException.h	(revision 1545)
+++ /code/branches/network/src/ois/OISException.h	(revision 1545)
@@ -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/network/src/ois/OISFactoryCreator.h
===================================================================
--- /code/branches/network/src/ois/OISFactoryCreator.h	(revision 1545)
+++ /code/branches/network/src/ois/OISFactoryCreator.h	(revision 1545)
@@ -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/network/src/ois/OISForceFeedback.cpp
===================================================================
--- /code/branches/network/src/ois/OISForceFeedback.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISForceFeedback.cpp	(revision 1545)
@@ -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/network/src/ois/OISForceFeedback.h
===================================================================
--- /code/branches/network/src/ois/OISForceFeedback.h	(revision 1545)
+++ /code/branches/network/src/ois/OISForceFeedback.h	(revision 1545)
@@ -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/network/src/ois/OISInputManager.cpp
===================================================================
--- /code/branches/network/src/ois/OISInputManager.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISInputManager.cpp	(revision 1545)
@@ -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/network/src/ois/OISInputManager.h
===================================================================
--- /code/branches/network/src/ois/OISInputManager.h	(revision 1545)
+++ /code/branches/network/src/ois/OISInputManager.h	(revision 1545)
@@ -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/network/src/ois/OISInterface.h
===================================================================
--- /code/branches/network/src/ois/OISInterface.h	(revision 1545)
+++ /code/branches/network/src/ois/OISInterface.h	(revision 1545)
@@ -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/network/src/ois/OISJoyStick.cpp
===================================================================
--- /code/branches/network/src/ois/OISJoyStick.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISJoyStick.cpp	(revision 1545)
@@ -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/network/src/ois/OISJoyStick.h
===================================================================
--- /code/branches/network/src/ois/OISJoyStick.h	(revision 1545)
+++ /code/branches/network/src/ois/OISJoyStick.h	(revision 1545)
@@ -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/network/src/ois/OISKeyboard.cpp
===================================================================
--- /code/branches/network/src/ois/OISKeyboard.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISKeyboard.cpp	(revision 1545)
@@ -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/network/src/ois/OISKeyboard.h
===================================================================
--- /code/branches/network/src/ois/OISKeyboard.h	(revision 1545)
+++ /code/branches/network/src/ois/OISKeyboard.h	(revision 1545)
@@ -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/network/src/ois/OISMouse.h
===================================================================
--- /code/branches/network/src/ois/OISMouse.h	(revision 1545)
+++ /code/branches/network/src/ois/OISMouse.h	(revision 1545)
@@ -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/network/src/ois/OISObject.cpp
===================================================================
--- /code/branches/network/src/ois/OISObject.cpp	(revision 1545)
+++ /code/branches/network/src/ois/OISObject.cpp	(revision 1545)
@@ -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/network/src/ois/OISObject.h
===================================================================
--- /code/branches/network/src/ois/OISObject.h	(revision 1545)
+++ /code/branches/network/src/ois/OISObject.h	(revision 1545)
@@ -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/network/src/ois/OISPrereqs.h
===================================================================
--- /code/branches/network/src/ois/OISPrereqs.h	(revision 1545)
+++ /code/branches/network/src/ois/OISPrereqs.h	(revision 1545)
@@ -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/network/src/ois/ReadMe.txt
===================================================================
--- /code/branches/network/src/ois/ReadMe.txt	(revision 1545)
+++ /code/branches/network/src/ois/ReadMe.txt	(revision 1545)
@@ -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/network/src/ois/linux/EventHelpers.cpp
===================================================================
--- /code/branches/network/src/ois/linux/EventHelpers.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/EventHelpers.cpp	(revision 1545)
@@ -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/network/src/ois/linux/EventHelpers.h
===================================================================
--- /code/branches/network/src/ois/linux/EventHelpers.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/EventHelpers.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxForceFeedback.cpp
===================================================================
--- /code/branches/network/src/ois/linux/LinuxForceFeedback.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxForceFeedback.cpp	(revision 1545)
@@ -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/network/src/ois/linux/LinuxForceFeedback.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxForceFeedback.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxForceFeedback.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxInputManager.cpp
===================================================================
--- /code/branches/network/src/ois/linux/LinuxInputManager.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxInputManager.cpp	(revision 1545)
@@ -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/network/src/ois/linux/LinuxInputManager.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxInputManager.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxInputManager.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxJoyStickEvents.cpp
===================================================================
--- /code/branches/network/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 1545)
@@ -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/network/src/ois/linux/LinuxJoyStickEvents.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxJoyStickEvents.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxJoyStickEvents.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxKeyboard.cpp
===================================================================
--- /code/branches/network/src/ois/linux/LinuxKeyboard.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxKeyboard.cpp	(revision 1545)
@@ -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(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/network/src/ois/linux/LinuxKeyboard.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxKeyboard.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxKeyboard.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxMouse.cpp
===================================================================
--- /code/branches/network/src/ois/linux/LinuxMouse.cpp	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxMouse.cpp	(revision 1545)
@@ -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/network/src/ois/linux/LinuxMouse.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxMouse.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxMouse.h	(revision 1545)
@@ -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/network/src/ois/linux/LinuxPrereqs.h
===================================================================
--- /code/branches/network/src/ois/linux/LinuxPrereqs.h	(revision 1545)
+++ /code/branches/network/src/ois/linux/LinuxPrereqs.h	(revision 1545)
@@ -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/network/src/ois/mac/MacHIDManager.cpp
===================================================================
--- /code/branches/network/src/ois/mac/MacHIDManager.cpp	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacHIDManager.cpp	(revision 1545)
@@ -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/network/src/ois/mac/MacHIDManager.h
===================================================================
--- /code/branches/network/src/ois/mac/MacHIDManager.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacHIDManager.h	(revision 1545)
@@ -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/network/src/ois/mac/MacHelpers.cpp
===================================================================
--- /code/branches/network/src/ois/mac/MacHelpers.cpp	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacHelpers.cpp	(revision 1545)
@@ -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/network/src/ois/mac/MacHelpers.h
===================================================================
--- /code/branches/network/src/ois/mac/MacHelpers.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacHelpers.h	(revision 1545)
@@ -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/network/src/ois/mac/MacInputManager.cpp
===================================================================
--- /code/branches/network/src/ois/mac/MacInputManager.cpp	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacInputManager.cpp	(revision 1545)
@@ -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/network/src/ois/mac/MacInputManager.h
===================================================================
--- /code/branches/network/src/ois/mac/MacInputManager.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacInputManager.h	(revision 1545)
@@ -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/network/src/ois/mac/MacKeyboard.cpp
===================================================================
--- /code/branches/network/src/ois/mac/MacKeyboard.cpp	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacKeyboard.cpp	(revision 1545)
@@ -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/network/src/ois/mac/MacKeyboard.h
===================================================================
--- /code/branches/network/src/ois/mac/MacKeyboard.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacKeyboard.h	(revision 1545)
@@ -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/network/src/ois/mac/MacMouse.cpp
===================================================================
--- /code/branches/network/src/ois/mac/MacMouse.cpp	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacMouse.cpp	(revision 1545)
@@ -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/network/src/ois/mac/MacMouse.h
===================================================================
--- /code/branches/network/src/ois/mac/MacMouse.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacMouse.h	(revision 1545)
@@ -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/network/src/ois/mac/MacPrereqs.h
===================================================================
--- /code/branches/network/src/ois/mac/MacPrereqs.h	(revision 1545)
+++ /code/branches/network/src/ois/mac/MacPrereqs.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32ForceFeedback.cpp
===================================================================
--- /code/branches/network/src/ois/win32/Win32ForceFeedback.cpp	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32ForceFeedback.cpp	(revision 1545)
@@ -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/network/src/ois/win32/Win32ForceFeedback.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32ForceFeedback.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32ForceFeedback.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32InputManager.cpp
===================================================================
--- /code/branches/network/src/ois/win32/Win32InputManager.cpp	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32InputManager.cpp	(revision 1545)
@@ -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/network/src/ois/win32/Win32InputManager.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32InputManager.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32InputManager.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32JoyStick.cpp
===================================================================
--- /code/branches/network/src/ois/win32/Win32JoyStick.cpp	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32JoyStick.cpp	(revision 1545)
@@ -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/network/src/ois/win32/Win32JoyStick.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32JoyStick.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32JoyStick.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32KeyBoard.cpp
===================================================================
--- /code/branches/network/src/ois/win32/Win32KeyBoard.cpp	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32KeyBoard.cpp	(revision 1545)
@@ -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/network/src/ois/win32/Win32KeyBoard.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32KeyBoard.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32KeyBoard.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32Mouse.cpp
===================================================================
--- /code/branches/network/src/ois/win32/Win32Mouse.cpp	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32Mouse.cpp	(revision 1545)
@@ -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/network/src/ois/win32/Win32Mouse.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32Mouse.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32Mouse.h	(revision 1545)
@@ -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/network/src/ois/win32/Win32Prereqs.h
===================================================================
--- /code/branches/network/src/ois/win32/Win32Prereqs.h	(revision 1545)
+++ /code/branches/network/src/ois/win32/Win32Prereqs.h	(revision 1545)
@@ -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/network/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/network/src/orxonox/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/orxonox/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,83 @@
+SET( ORXONOX_SRC_FILES
+  GraphicsEngine.cc
+  Main.cc
+  Orxonox.cc
+  Settings.cc
+
+  console/InGameConsole.cc
+  hud/HUD.cc
+  hud/BarOverlayElement.cc
+  hud/RadarOverlayElement.cc
+  hud/RadarObject.cc
+  hud/Navigation.cc
+  particle/ParticleInterface.cc
+  tolua/tolua_bind.cc
+
+  tools/BillboardSet.cc
+  tools/Light.cc
+  tools/Mesh.cc
+  tools/Timer.cc
+
+  objects/Ambient.cc
+  objects/Camera.cc
+  objects/CameraHandler.cc
+  objects/Explosion.cc
+  objects/Model.cc
+  objects/NPC.cc
+  objects/Projectile.cc
+  objects/RotatingProjectile.cc
+  objects/Skybox.cc
+  objects/SpaceShip.cc
+  objects/SpaceShipAI.cc
+  objects/Tickable.cc
+  objects/WorldEntity.cc
+
+#  objects/weapon/AmmunitionDump.cc
+#  objects/weapon/BarrelGun.cc
+#  objects/weapon/BaseWeapon.cc
+#  objects/weapon/Bullet.cc
+#  objects/weapon/BulletManager.cc
+#  objects/weapon/WeaponStation.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h
+  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
+  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}
+  tinyxml
+  tolualib
+  ois
+  util
+  core
+  audio
+  network
+)
+
Index: /code/branches/network/src/orxonox/GraphicsEngine.cc
===================================================================
--- /code/branches/network/src/orxonox/GraphicsEngine.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/GraphicsEngine.cc	(revision 1545)
@@ -0,0 +1,468 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
+ *
+ */
+
+ /**
+    @file orxonox.cc
+    @brief Orxonox class
+  */
+
+#include "OrxonoxStableHeaders.h"
+#include "GraphicsEngine.h"
+
+#include <fstream>
+
+#include <OgreConfigFile.h>
+#include <OgreException.h>
+#include <OgreLogManager.h>
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Debug.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+
+#include "console/InGameConsole.h"
+#include "Settings.h"
+
+
+namespace orxonox {
+  /**
+    @brief Returns the singleton instance and creates it the first time.
+    @return The only instance of GraphicsEngine.
+  */
+  /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
+  {
+    static GraphicsEngine theOnlyInstance;
+    return theOnlyInstance;
+  }
+
+  /**
+    @brief Only use constructor to initialise variables and pointers!
+  */
+  GraphicsEngine::GraphicsEngine() :
+    root_(0),
+    scene_(0),
+    renderWindow_(0)
+  {
+    RegisterObject(GraphicsEngine);
+
+    this->setConfigValues();
+    CCOUT(4) << "Constructed" << std::endl;
+  }
+
+  void GraphicsEngine::setConfigValues()
+  {
+    SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
+    SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
+    SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
+    SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
+                                                             Use \"\" to suppress log file creation.");
+    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
+    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
+    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
+  }
+
+  /**
+    @brief Called after main() --> call destroyObjects()!
+  */
+  GraphicsEngine::~GraphicsEngine()
+  {
+    this->destroy();
+  }
+
+  /**
+    @brief Destroys all the internal objects. Call this method when you
+           normally would call the destructor.
+  */
+  void GraphicsEngine::destroy()
+  {
+    CCOUT(4) << "Destroying objects..." << std::endl;
+    Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
+    if (this->root_)
+      delete this->root_;
+    this->root_ = 0;
+    this->scene_ = 0;
+    this->renderWindow_ = 0;
+    // delete the ogre log and the logManager (since we have created it).
+    if (Ogre::LogManager::getSingletonPtr() != 0)
+    {
+      Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
+      Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
+      delete Ogre::LogManager::getSingletonPtr();
+    }
+    CCOUT(4) << "Destroying objects done" << std::endl;
+  }
+
+  /**
+    @brief Creates the Ogre Root object and sets up the ogre log.
+  */
+  bool GraphicsEngine::setup()
+  {
+    CCOUT(3) << "Setting up..." << std::endl;
+    // temporary overwrite of dataPath, change ini file for permanent change
+
+// TODO: LogManager doesn't work on specific systems. The why is unknown yet.
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+    // create a logManager
+    // note: If there's already a logManager, Ogre will complain by a failed assertation.
+    // but that shouldn't happen, since this is the first time to create a logManager..
+    Ogre::LogManager* logger = new Ogre::LogManager();
+    CCOUT(4) << "Ogre LogManager created" << std::endl;
+
+    // create our own log that we can listen to
+    Ogre::Log *myLog;
+    if (this->ogreLogFile_ == "")
+      myLog = logger->createLog("ogre.log", true, false, true);
+    else
+      myLog = logger->createLog(this->ogreLogFile_, true, false, false);
+    CCOUT(4) << "Ogre Log created" << std::endl;
+
+    myLog->setLogDetail(Ogre::LL_BOREME);
+    myLog->addListener(this);
+#endif
+
+    // Root will detect that we've already created a Log
+    CCOUT(4) << "Creating Ogre Root..." << std::endl;
+
+    if (ogrePluginsFile_ == "")
+    {
+      COUT(1) << "Error: Ogre plugins file set to \"\". Cannot load." << std::endl;
+      return false;
+    }
+    if (ogreConfigFile_ == "")
+    {
+      COUT(1) << "Error: Ogre config file set to \"\". Cannot load." << std::endl;
+      return false;
+    }
+    if (ogreLogFile_ == "")
+    {
+      COUT(1) << "Error: Ogre log file set to \"\". Cannot load." << std::endl;
+      return false;
+    }
+
+    try
+    {
+      root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
+    }
+    catch (Ogre::Exception ex)
+    {
+      COUT(2) << "Error: There was an exception when creating Ogre Root." << std::endl;
+      return false;
+    }
+
+    if (!root_->getInstalledPlugins().size())
+    {
+      COUT(1) << "Error: No plugins declared. Cannot load Ogre." << std::endl;
+      COUT(0) << "Is the plugins file correctly declared?" << std::endl;
+      return false;
+    }
+
+#if 0
+    // tame the ogre ouput so we don't get all the mess in the console
+    Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
+    defaultLog->setDebugOutputEnabled(false);
+    defaultLog->setLogDetail(Ogre::LL_BOREME);
+    defaultLog->addListener(this);
+#endif
+
+    CCOUT(4) << "Creating Ogre Root done" << std::endl;
+
+    // specify where Ogre has to look for resources. This call doesn't parse anything yet!
+    if (!declareRessourceLocations())
+      return false;
+
+    CCOUT(3) << "Set up done." << std::endl;
+    return true;
+  }
+
+  bool GraphicsEngine::declareRessourceLocations()
+  {
+    CCOUT(4) << "Declaring Resources" << std::endl;
+    //TODO: Specify layout of data file and maybe use xml-loader
+    //TODO: Work with ressource groups (should be generated by a special loader)
+
+    if (resourceFile_ == "")
+    {
+      COUT(1) << "Error: Resource file set to \"\". Cannot load." << std::endl;
+      return false;
+    }
+
+    // Load resource paths from data file using configfile ressource type
+    Ogre::ConfigFile cf;
+    try
+    {
+      cf.load(Settings::getDataPath() + resourceFile_);
+    }
+    catch (Ogre::Exception ex)
+    {
+      COUT(1) << "Error: Could not load resources.cfg in path " << Settings::getDataPath() << std::endl;
+      COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
+      return false;
+    }
+
+    // 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(2) << "Exception while reading resources.cfg. Proceeding.." << ex.getDescription() << std::endl;
+      }
+    }
+    return true;
+  }
+
+  bool GraphicsEngine::loadRenderer()
+  {
+    CCOUT(4) << "Configuring Renderer" << std::endl;
+
+    // check for file existence because Ogre displays exceptions if not
+    std::ifstream probe;
+    probe.open(ogreConfigFile_.c_str());
+    if (!probe)
+    {
+      // create a zero sized file
+      std::ofstream creator;
+      creator.open(ogreConfigFile_.c_str());
+      creator.close();
+    }
+    else
+      probe.close();
+
+    if (!root_->restoreConfig())
+      if (!root_->showConfigDialog())
+        return false;
+
+    CCOUT(4) << "Creating render window" << std::endl;
+    try
+    {
+      this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
+    }
+    catch (Ogre::Exception ex)
+    {
+      COUT(2) << "Error: There was an exception when initialising Ogre Root." << std::endl;
+      return false;
+    }
+
+    if (!root_->isInitialised())
+    {
+      CCOUT(2) << "Error: Initialising Ogre root object failed." << std::endl;
+      return false;
+    }
+    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
+    return true;
+  }
+
+  bool GraphicsEngine::initialiseResources()
+  {
+    CCOUT(4) << "Initialising resources" << std::endl;
+    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+    try
+    {
+      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 (Ogre::Exception e)
+    {
+      CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
+      CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * @brief Creates the SceneManager
+   */
+  bool GraphicsEngine::createNewScene()
+  {
+    CCOUT(4) << "Creating new SceneManager..." << std::endl;
+    if (scene_)
+    {
+      CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
+      return false;
+    }
+    scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
+    CCOUT(3) << "Created SceneManager: " << scene_ << std::endl;
+    return true;
+  }
+
+  /**
+    Returns the window handle of the render window.
+    At least the InputHandler uses this to create the OIS::InputManager
+    @return The window handle of the render window
+  */
+  size_t GraphicsEngine::getWindowHandle()
+  {
+    if (this->renderWindow_)
+    {
+      size_t windowHnd = 0;
+      this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
+      return windowHnd;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    Get the width of the current render window
+    @return The width of the current render window
+  */
+  int GraphicsEngine::getWindowWidth() const
+  {
+    if (this->renderWindow_)
+      return this->renderWindow_->getWidth();
+    else
+      return 0;
+  }
+
+  /**
+    Get the height of the current render window
+    @return The height of the current render window
+  */
+  int GraphicsEngine::getWindowHeight() const
+  {
+    if (this->renderWindow_)
+      return this->renderWindow_->getHeight();
+    else
+      return 0;
+  }
+
+  /**
+    @brief Returns the window aspect ratio height/width.
+    @return The ratio
+  */
+  float GraphicsEngine::getWindowAspectRatio() const
+  {
+    if (this->renderWindow_)
+        return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
+    else
+        return 1.0f;
+  }
+
+  /**
+    @brief Method called by the LogListener interface from Ogre.
+    We use it to capture Ogre log messages and handle it ourselves.
+    @param message The message to be logged
+    @param lml The message level the log is using
+    @param maskDebug If we are printing to the console or not
+    @param logName the name of this log (so you can have several listeners
+                   for different logs, and identify them)
+  */
+  void GraphicsEngine::messageLogged(const std::string& message,
+    Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName)
+  {
+    int orxonoxLevel;
+    switch (lml)
+    {
+      case Ogre::LML_TRIVIAL:
+        orxonoxLevel = this->ogreLogLevelTrivial_;
+        break;
+      case Ogre::LML_NORMAL:
+        orxonoxLevel = this->ogreLogLevelNormal_;
+        break;
+      case Ogre::LML_CRITICAL:
+        orxonoxLevel = this->ogreLogLevelCritical_;
+        break;
+      default:
+        orxonoxLevel = 0;
+    }
+    OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+        << "Ogre: " << message << std::endl;
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
+  {
+    // note: this doesn't change the window extents
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  * @note GraphicsEngine has a render window stored itself. This is the same
+  *       as rw. But we have to be careful when using multiple render windows!
+  */
+  void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
+  {
+    // change the mouse clipping size for absolute mouse movements
+    int w = rw->getWidth();
+    int h = rw->getHeight();
+    InputManager::setWindowExtents(w, h);
+    InGameConsole::getInstance().resize();
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
+  {
+    // note: this doesn't change the window extents
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
+  {
+    // using CommandExecutor in order to avoid depending on Orxonox class.
+    CommandExecutor::execute("exit", false);
+  }
+
+}
Index: /code/branches/network/src/orxonox/GraphicsEngine.h
===================================================================
--- /code/branches/network/src/orxonox/GraphicsEngine.h	(revision 1545)
+++ /code/branches/network/src/orxonox/GraphicsEngine.h	(revision 1545)
@@ -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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, 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 <OgreLog.h>
+#include <OgreRenderWindow.h>
+#include <OgreWindowEventUtilities.h>
+#include "core/OrxonoxClass.h"
+
+
+namespace orxonox {
+
+    /**
+    @brief Graphics engine manager class
+    */
+    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
+    {
+        public:
+            void setConfigValues();
+            bool setup();
+            bool declareRessourceLocations();
+            bool loadRenderer();
+            bool initialiseResources();
+            bool createNewScene();
+
+            void destroy();
+
+            Ogre::SceneManager* getSceneManager() { return scene_; }
+
+            // several window properties
+            Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
+            size_t getWindowHandle();
+            int getWindowWidth() const;
+            int getWindowHeight() const;
+            float getWindowAspectRatio() const;
+            float getAverageFPS() const
+            { if (renderWindow_) return this->renderWindow_->getAverageFPS(); else return 0.0f; }
+
+            void windowMoved       (Ogre::RenderWindow* rw);
+            void windowResized     (Ogre::RenderWindow* rw);
+            void windowFocusChanged(Ogre::RenderWindow* rw);
+            void windowClosed      (Ogre::RenderWindow* rw);
+
+            static GraphicsEngine& getSingleton();
+            static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
+
+
+        private:
+            // don't mess with singletons
+            GraphicsEngine();
+            ~GraphicsEngine();
+            GraphicsEngine(GraphicsEngine&) { }
+
+            //! Method called by the LogListener from Ogre
+            void messageLogged(const std::string&, Ogre::LogMessageLevel,
+                             bool, const std::string&);
+
+            Ogre::Root*         root_;              //!< Ogre's root
+            Ogre::SceneManager* scene_;             //!< scene manager of the game
+            Ogre::RenderWindow* renderWindow_;      //!< the current render window
+            std::string         resourceFile_;      //!< resources file name
+            std::string         ogreConfigFile_;    //!< ogre config file name
+            std::string         ogrePluginsFile_;   //!< ogre plugins file name
+            std::string         ogreLogFile_;       //!< log file name for Ogre log messages
+            int ogreLogLevelTrivial_;               //!< Corresponding Orxonx debug level for LL_TRIVIAL
+            int ogreLogLevelNormal_;                //!< Corresponding Orxonx debug level for LL_NORMAL
+            int ogreLogLevelCritical_;              //!< Corresponding Orxonx debug level for LL_CRITICAL
+    };
+}
+
+#endif /* _GraphicsEngine_H__ */
Index: /code/branches/network/src/orxonox/Main.cc
===================================================================
--- /code/branches/network/src/orxonox/Main.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/Main.cc	(revision 1545)
@@ -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:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /**
+ @file
+ @brief Entry point of the program. Platform specific code.
+  */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <exception>
+
+#include "util/OrxonoxPlatform.h"
+#include "core/SignalHandler.h"
+#include "Orxonox.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)
+{
+  //try {
+    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
+    Orxonox* orx = Orxonox::getSingleton();
+
+    bool res = false;
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+    res = orx->init(argc, argv, macBundlePath());
+#else
+    res = orx->init(argc, argv);
+#endif
+
+    if (res)
+      orx->start();
+    orx->destroySingleton();
+  /*}
+  catch (std::exception &ex)
+  {
+    std::cerr << "Exception:\n";
+    std::cerr << ex.what() << "\n";
+    return 1;
+  }*/
+
+  return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
Index: /code/branches/network/src/orxonox/Orxonox.cc
===================================================================
--- /code/branches/network/src/orxonox/Orxonox.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/Orxonox.cc	(revision 1545)
@@ -0,0 +1,537 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *
+ */
+
+/**
+ @file
+ @brief Orxonox Main Class
+ */
+
+// Precompiled Headers
+#include "OrxonoxStableHeaders.h"
+#include "Orxonox.h"
+
+//****** STD *******
+#include <deque>
+
+//****** OGRE ******
+#include <OgreFrameListener.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayManager.h>
+#include <OgreRoot.h>
+#include <OgreTimer.h>
+#include <OgreWindowEventUtilities.h>
+
+//***** ORXONOX ****
+// util
+//#include "util/Sleep.h"
+#include "util/ArgReader.h"
+
+// core
+#include "core/ConfigFileManager.h"
+#include "core/ConsoleCommand.h"
+#include "core/Debug.h"
+#include "core/Loader.h"
+#include "core/input/InputManager.h"
+#include "core/TclBind.h"
+#include "core/Core.h"
+
+// audio
+#include "audio/AudioManager.h"
+
+// network
+#include "network/Server.h"
+#include "network/Client.h"
+
+// objects and tools
+#include "hud/HUD.h"
+#include "objects/Tickable.h"
+
+#include "GraphicsEngine.h"
+#include "Settings.h"
+
+// FIXME: is this really file scope?
+// globals for the server or client
+network::Client *client_g = 0;
+network::Server *server_g = 0;
+
+namespace orxonox
+{
+  SetConsoleCommandShortcut(Orxonox, exit).setKeybindMode(KeybindMode::OnPress);
+  SetConsoleCommandShortcut(Orxonox, slomo).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false);
+  SetConsoleCommandShortcut(Orxonox, setTimeFactor).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0);
+
+  /**
+    @brief Reference to the only instance of the class.
+  */
+  Orxonox *Orxonox::singletonRef_s = 0;
+
+  /**
+   * Create a new instance of Orxonox. Avoid doing any actual work here.
+   */
+  Orxonox::Orxonox() :
+    ogre_(0),
+    //auMan_(0),
+    timer_(0),
+    // turn on frame smoothing by setting a value different from 0
+    frameSmoothingTime_(0.0f),
+    orxonoxHUD_(0),
+    bAbort_(false),
+    timefactor_(1.0f),
+    mode_(STANDALONE),
+    serverIp_(""),
+    serverPort_(NETWORK_PORT)
+  {
+  }
+
+  /**
+   * Destruct Orxonox.
+   */
+  Orxonox::~Orxonox()
+  {
+    // keep in mind: the order of deletion is very important!
+//    if (this->orxonoxHUD_)
+//      delete this->orxonoxHUD_;
+    Loader::close();
+    InputManager::destroy();
+    //if (this->auMan_)
+    //  delete this->auMan_;
+    if (this->timer_)
+      delete this->timer_;
+    GraphicsEngine::getSingleton().destroy();
+
+    if (network::Client::getSingleton())
+      network::Client::destroySingleton();
+    if (server_g)
+      delete network::Server::getSingleton();
+  }
+
+
+  /**
+    Asks the mainloop nicely to abort.
+  */
+  void Orxonox::abortRequest()
+  {
+    COUT(3) << "Orxonox: Abort requested." << std::endl;
+    bAbort_ = true;
+  }
+
+  /**
+   * @return singleton reference
+   */
+  Orxonox* Orxonox::getSingleton()
+  {
+    if (!singletonRef_s)
+      singletonRef_s = new Orxonox();
+    return singletonRef_s;
+  }
+
+  /**
+    @brief Destroys the Orxonox singleton.
+  */
+  void Orxonox::destroySingleton()
+  {
+    if (singletonRef_s)
+      delete singletonRef_s;
+    singletonRef_s = 0;
+  }
+
+  /**
+   * initialization of Orxonox object
+   * @param argc argument counter
+   * @param argv list of argumenst
+   * @param path path to config (in home dir or something)
+   */
+  bool Orxonox::init(int argc, char **argv)
+  {
+#ifdef _DEBUG
+    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
+#else
+    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
+#endif
+    Factory::createClassHierarchy();
+
+    std::string mode;
+    std::string tempDataPath;
+
+    ArgReader ar(argc, argv);
+    ar.checkArgument("mode", &mode, false);
+    ar.checkArgument("data", &tempDataPath, false);
+    ar.checkArgument("ip",   &serverIp_, false);
+    ar.checkArgument("port", &serverPort_, false);
+    if(ar.errorHandling())
+    {
+      COUT(1) << "Error while parsing command line arguments" << std::endl;
+      COUT(1) << ar.getErrorString();
+      COUT(0) << "Usage:" << std::endl << "orxonox [mode client|server|dedicated|standalone] "
+        << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
+      return false;
+    }
+
+    if (mode == "client")
+      mode_ = CLIENT;
+    else if (mode == "server")
+      mode_ = SERVER;
+    else if (mode == "dedicated")
+      mode_ = DEDICATED;
+    else
+    {
+      if (mode == "")
+        mode = "standalone";
+      if (mode != "standalone")
+      {
+        COUT(2) << "Warning: mode \"" << mode << "\" doesn't exist. "
+          << "Defaulting to standalone" << std::endl;
+        mode = "standalone";
+      }
+      mode_ = STANDALONE;
+    }
+    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
+
+    if (tempDataPath != "")
+    {
+      if (tempDataPath[tempDataPath.size() - 1] != '/')
+        tempDataPath += "/";
+      Settings::tsetDataPath(tempDataPath);
+    }
+
+    // initialise TCL
+    TclBind::getInstance().setDataPath(Settings::getDataPath());
+
+    //if (mode_ == DEDICATED)
+      // TODO: decide what to do here
+    //else
+
+    // for playable server, client and standalone, the startup
+    // procedure until the GUI is identical
+
+    ogre_ = &GraphicsEngine::getSingleton();
+    if (!ogre_->setup())       // creates ogre root and other essentials
+      return false;
+
+    return true;
+  }
+
+  /**
+   * start modules
+   */
+  bool Orxonox::start()
+  {
+    if (mode_ == DEDICATED)
+    {
+      // do something else
+    }
+    else
+    { // not dedicated server
+      if (!ogre_->loadRenderer())    // creates the render window
+        return false;
+
+      // Calls the InputManager which sets up the input devices.
+      // The render window width and height are used to set up the mouse movement.
+      if (!InputManager::initialise(ogre_->getWindowHandle(),
+            ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
+        return false;
+
+      // TODO: Spread this so that this call only initialises things needed for the GUI
+      if (!ogre_->initialiseResources())
+        return false;
+
+      // TOOD: load the GUI here
+      // set InputManager to GUI mode
+      InputManager::setInputState(InputManager::IS_GUI);
+      // TODO: run GUI here
+
+      // The following lines depend very much on the GUI output, so they're probably misplaced here..
+
+      InputManager::setInputState(InputManager::IS_NONE);
+
+      // create Ogre SceneManager
+      ogre_->createNewScene();
+
+      if (!loadPlayground())
+        return false;
+    }
+
+    switch (mode_)
+    {
+    case SERVER:
+      if (!serverLoad())
+        return false;
+      break;
+    case CLIENT:
+      if (!clientLoad())
+        return false;
+      break;
+    case DEDICATED:
+      if (!serverLoad())
+        return false;
+      break;
+    default:
+      if (!standaloneLoad())
+        return false;
+    }
+
+    InputManager::setInputState(InputManager::IS_NORMAL);
+
+    return startRenderLoop();
+  }
+
+  /**
+   * Loads everything in the scene except for the actual objects.
+   * This includes HUD, Console..
+   */
+  bool Orxonox::loadPlayground()
+  {
+    // Init audio
+    //auMan_ = new audio::AudioManager();
+    //auMan_->ambientAdd("a1");
+    //auMan_->ambientAdd("a2");
+    //auMan_->ambientAdd("a3");
+    //auMan->ambientAdd("ambient1");
+    //auMan_->ambientStart();
+
+    // Load the HUD
+    COUT(3) << "Orxonox: Loading HUD..." << std::endl;
+    orxonoxHUD_ = &HUD::getSingleton();
+    return true;
+  }
+
+  /**
+   * Level loading method for server mode.
+   */
+  bool Orxonox::serverLoad()
+  {
+    COUT(2) << "Loading level in server mode" << std::endl;
+
+    //server_g = new network::Server(serverPort_);
+    server_g = network::Server::createSingleton(serverPort_);
+
+    if (!loadScene())
+      return false;
+
+    server_g->open();
+
+    return true;
+  }
+
+  /**
+   * Level loading method for client mode.
+   */
+  bool Orxonox::clientLoad()
+  {
+    COUT(2) << "Loading level in client mode" << std::endl;\
+
+    if (serverIp_.compare("") == 0)
+      client_g = network::Client::createSingleton();
+    else
+
+      client_g = network::Client::createSingleton(serverIp_, serverPort_);
+
+    if(!client_g->establishConnection())
+      return false;
+    client_g->tick(0);
+
+    return true;
+  }
+
+  /**
+   * Level loading method for standalone mode.
+   */
+  bool Orxonox::standaloneLoad()
+  {
+    COUT(2) << "Loading level in standalone mode" << std::endl;
+
+    if (!loadScene())
+      return false;
+
+    return true;
+  }
+
+  /**
+   * Helper method to load a level.
+   */
+  bool Orxonox::loadScene()
+  {
+    Level* startlevel = new Level("levels/sample.oxw");
+    Loader::open(startlevel);
+    
+    return true;
+  }
+
+
+  /**
+    Main loop of the orxonox game.
+    About the loop: The design is almost exactly like the one in ogre, so that
+    if any part of ogre registers a framelisteners, it will still behave
+    correctly. Furthermore the time smoothing feature from ogre has been
+    implemented too. If turned on (see orxonox constructor), it will calculate
+    the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
+  */
+  bool Orxonox::startRenderLoop()
+  {
+    // first check whether ogre root object has been created
+    if (Ogre::Root::getSingletonPtr() == 0)
+    {
+      COUT(2) << "Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
+      return false;
+    }
+    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
+
+
+    // Contains the times of recently fired events
+    // eventTimes[4] is the list for the times required for the fps counter
+    std::deque<unsigned long> eventTimes[3];
+    // Clear event times
+    for (int i = 0; i < 3; ++i)
+      eventTimes[i].clear();
+
+    // use the ogre timer class to measure time.
+    if (!timer_)
+      timer_ = new Ogre::Timer();
+    timer_->reset();
+
+    float renderTime = 0.0f;
+    float frameTime = 0.0f;
+    clock_t time = 0;
+
+    //Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();
+    //Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport();
+    
+    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom");
+    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur");
+
+    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
+    while (!bAbort_)
+    {
+      // get current time
+      unsigned long now = timer_->getMilliseconds();
+
+      // create an event to pass to the frameStarted method in ogre
+      Ogre::FrameEvent evt;
+      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
+      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]);
+      frameTime += evt.timeSinceLastFrame;
+
+      // show the current time in the HUD
+      // HUD::getSingleton().setTime(now);
+      if (mode_ != DEDICATED && frameTime > 0.4f)
+      {
+        HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime);
+        frameTime = 0.0f;
+        renderTime = 0.0f;
+      }
+
+      // tick the core
+      Core::tick((float)evt.timeSinceLastFrame);
+      // Call those objects that need the real time
+      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
+        it->tick((float)evt.timeSinceLastFrame);
+      // Call the scene objects
+      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
+        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
+      //AudioManager::tick();
+      if (client_g)
+        client_g->tick((float)evt.timeSinceLastFrame);
+      if (server_g)
+        server_g->tick((float)evt.timeSinceLastFrame);
+
+      // don't forget to call _fireFrameStarted in ogre to make sure
+      // everything goes smoothly
+      ogreRoot._fireFrameStarted(evt);
+
+      // get current time
+      now = timer_->getMilliseconds();
+      calculateEventTime(now, eventTimes[2]);
+
+      if (mode_ != DEDICATED)
+      {
+        // Pump messages in all registered RenderWindows
+        // This calls the WindowEventListener objects.
+        Ogre::WindowEventUtilities::messagePump();
+
+        // render
+        ogreRoot._updateAllRenderTargets();
+      }
+
+      // get current time
+      now = timer_->getMilliseconds();
+
+      // create an event to pass to the frameEnded method in ogre
+      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
+      renderTime += calculateEventTime(now, eventTimes[2]);
+
+      // again, just to be sure ogre works fine
+      ogreRoot._fireFrameEnded(evt);
+      //msleep(200);
+    }
+
+    if (mode_ == CLIENT)
+      network::Client::getSingleton()->closeConnection();
+    else if (mode_ == SERVER)
+      server_g->close();
+
+    return true;
+  }
+
+  /**
+    Method for calculating the average time between recently fired events.
+    Code directly taken from OgreRoot.cc
+    @param now The current time in ms.
+    @param type The type of event to be considered.
+  */
+  float Orxonox::calculateEventTime(unsigned long now, std::deque<unsigned long> &times)
+  {
+    // Calculate the average time passed between events of the given type
+    // during the last frameSmoothingTime_ seconds.
+
+    times.push_back(now);
+
+    if(times.size() == 1)
+      return 0;
+
+    // Times up to frameSmoothingTime_ seconds old should be kept
+    unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f);
+
+    // Find the oldest time to keep
+    std::deque<unsigned long>::iterator it  = times.begin();
+    // We need at least two times
+    std::deque<unsigned long>::iterator end = times.end() - 2;
+
+    while(it != end)
+    {
+      if (now - *it > discardThreshold)
+        ++it;
+      else
+        break;
+    }
+
+    // Remove old times
+    times.erase(times.begin(), it);
+
+    return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000);
+  }
+}
Index: /code/branches/network/src/orxonox/Orxonox.h
===================================================================
--- /code/branches/network/src/orxonox/Orxonox.h	(revision 1545)
+++ /code/branches/network/src/orxonox/Orxonox.h	(revision 1545)
@@ -0,0 +1,111 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *
+ */
+
+/**
+ @file  Orxonox.h
+ @brief Main Orxonox Class File
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _Orxonox_H__
+#define _Orxonox_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+#include "audio/AudioPrereqs.h"
+
+#include "GraphicsEngine.h"
+
+namespace orxonox {
+
+  enum gameMode{
+    SERVER,
+    CLIENT,
+    STANDALONE,
+    DEDICATED
+  };
+
+  //! Orxonox singleton class
+  class _OrxonoxExport Orxonox
+  {
+    public:
+      bool init(int argc, char **argv);
+      bool start();
+
+      void abortRequest();
+      //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
+
+      static Orxonox* getSingleton();
+      static void destroySingleton();
+
+      static inline void slomo(float factor) { Orxonox::getSingleton()->timefactor_ = factor; }
+      static inline void setTimeFactor(float factor = 1.0) { Orxonox::getSingleton()->timefactor_ = factor; }
+      static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; }
+      static inline void exit() { Orxonox::getSingleton()->abortRequest(); }
+
+   private:
+      // don't mess with singletons
+      Orxonox();
+      Orxonox(Orxonox& instance);
+      Orxonox& operator=(const Orxonox& instance);
+      ~Orxonox();
+
+      bool loadPlayground();
+
+      bool serverLoad();
+      bool clientLoad();
+      bool standaloneLoad();
+
+      bool loadScene();
+
+      bool startRenderLoop();
+
+      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
+
+    private:
+      GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
+      //audio::AudioManager*  auMan_;         //!< audio manager
+      Ogre::Timer*          timer_;         //!< Main loop timer
+      // TODO: make this a config-value by creating a config class for orxonox
+      float                 frameSmoothingTime_;
+      HUD*                  orxonoxHUD_;
+      bool                  bAbort_;        //!< aborts the render loop if true
+      float                 timefactor_;    //!< A factor to change the gamespeed
+
+      // this is used to identify the mode (server/client/...) we're in
+      gameMode              mode_;
+      std::string           serverIp_;
+      int                   serverPort_;
+
+      static Orxonox *singletonRef_s;
+  };
+}
+#endif /* _Orxonox_H__ */
Index: /code/branches/network/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/network/src/orxonox/OrxonoxPrereqs.h	(revision 1545)
+++ /code/branches/network/src/orxonox/OrxonoxPrereqs.h	(revision 1545)
@@ -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:
+ *      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 {
+  class GraphicsEngine;
+  class Orxonox;
+
+  // objects
+  class Ambient;
+  class Camera;
+  class Explosion;
+  class Fighter;
+  class Model;
+  class NPC;
+  class Projectile;
+  class Skybox;
+  class SpaceShip;
+  class SpaceShipAI;
+  class WorldEntity;
+
+  class AmmunitionDump;
+  class Bullet;
+  class BulletManager;
+  class BaseWeapon;
+  class BarrelGun;
+  class WeaponStation;
+
+  // tools
+  class BillboardSet;
+  class Light;
+  class Mesh;
+  template <class T>
+  class Timer;
+  class TimerBase;
+
+  // particle
+  class ParticleInterface;
+
+  // hud
+  class BarOverlayElement;
+  class HUD;
+  class Navigation;
+  class RadarObject;
+  class RadarOverlayElement;
+
+  //console
+  class InGameConsole;
+}
+
+
+#endif /* _OrxonoxPrereqs_H__ */
Index: /code/branches/network/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- /code/branches/network/src/orxonox/OrxonoxStableHeaders.h	(revision 1545)
+++ /code/branches/network/src/orxonox/OrxonoxStableHeaders.h	(revision 1545)
@@ -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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file  OrxonoxStableHeaders.h
+ @brief Contains the bigger (or smaller) header files in order to precompile them with MSVC
+ */
+
+#ifndef _OrxonoxStableHeaders_H__
+#define _OrxonoxStableHeaders_H__
+
+#include "util/OrxonoxPlatform.h"
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+
+// 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
+// not including the entire Ogre.h doesn't exceed the default heap size for pch
+//#include <Ogre.h>
+#include <OgreBillboardSet.h>
+#include <OgreCamera.h>
+#include <OgreColourValue.h>
+#include <OgreConfigFile.h>
+#include <OgreEntity.h>
+#include <OgreException.h>
+#include <OgreFrameListener.h>
+#include <OgreLight.h>
+#include <OgreLog.h>
+#include <OgreLogManager.h>
+#include <OgreMath.h>
+#include <OgreMatrix3.h>
+#include <OgreMatrix4.h>
+#include <OgreMesh.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreParticleEmitter.h>
+#include <OgreParticleSystem.h>
+#include <OgreQuaternion.h>
+#include <OgreResourceGroupManager.h>
+#include <OgreRenderWindow.h>
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreString.h>
+#include <OgreStringConverter.h>
+#include <OgreTextureManager.h>
+#include <OgreTimer.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector3.h>
+#include <OgreViewport.h>
+#include <OgreWindowEventUtilities.h>
+
+//-----------------------------------------------------------------------
+// ORXONOX HEADERS
+//-----------------------------------------------------------------------
+
+#include "ois/OIS.h"
+#include "cpptcl/CppTcl.h"
+#include "tinyxml/ticpp.h"
+#include "tinyxml/tinyxml.h"
+
+#include "util/Convert.h"
+#include "util/Math.h"
+#include "util/Multitype.h"
+#include "util/MultiTypeMath.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/Debug.h"
+#include "core/OutputBuffer.h"
+#include "core/OutputHandler.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 /* Compiler MSVC */
+
+#endif /* _OrxonoxStableHeaders_H__ */
Index: /code/branches/network/src/orxonox/PrecompiledHeaderFiles.cc
===================================================================
--- /code/branches/network/src/orxonox/PrecompiledHeaderFiles.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/PrecompiledHeaderFiles.cc	(revision 1545)
@@ -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/network/src/orxonox/Settings.cc
===================================================================
--- /code/branches/network/src/orxonox/Settings.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/Settings.cc	(revision 1545)
@@ -0,0 +1,105 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+  /**
+    @brief Constructor: Registers the object and sets the config-values.
+  */
+  Settings::Settings()
+  {
+    RegisterRootObject(Settings);
+    setConfigValues();
+  }
+
+  Settings::~Settings()
+  {
+  }
+
+  /**
+    @brief Returns a unique instance of Core.
+    @return The instance
+  */
+  Settings& Settings::getSingleton()
+  {
+    static Settings instance;
+    return instance;
+  }
+
+  /**
+    @brief Function to collect the SetConfigValue-macro calls.
+  */
+  void Settings::setConfigValues()
+  {
+    SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.");
+    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);
+  }
+
+  /*static*/ void Settings::tsetDataPath(const std::string& path)
+  {
+    getSingleton()._tsetDataPath(path);
+  }
+
+  /**
+    @brief Returns the relative path to the game data.
+    @return The path to the game data
+  */
+  /*static*/ const std::string& Settings::getDataPath()
+  {
+    return getSingleton().dataPath_;
+  }
+}
Index: /code/branches/network/src/orxonox/Settings.h
===================================================================
--- /code/branches/network/src/orxonox/Settings.h	(revision 1545)
+++ /code/branches/network/src/orxonox/Settings.h	(revision 1545)
@@ -0,0 +1,67 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 Definition 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"
+
+namespace orxonox
+{
+  class _OrxonoxExport Settings : public OrxonoxClass
+  {
+    public:
+      void setConfigValues();
+
+      static const std::string& getDataPath();
+
+      static void tsetDataPath(const std::string& path);
+
+    private:
+      Settings();
+      Settings(const Settings& instance);
+      ~Settings();
+      static Settings& getSingleton();
+
+      void _tsetDataPath(const std::string& path);
+
+      std::string dataPath_;               //!< Path to the game data
+  };
+}
+
+#endif /* _Settings_H__ */
Index: /code/branches/network/src/orxonox/console/InGameConsole.cc
===================================================================
--- /code/branches/network/src/orxonox/console/InGameConsole.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/console/InGameConsole.cc	(revision 1545)
@@ -0,0 +1,562 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <OgreStringConverter.h>
+
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+
+#define LINES 30
+#define CHAR_WIDTH1 7.78 //34 // fix this please - determine the char-width dynamically
+#define CHAR_WIDTH2 8.28 // fix this please - determine the char-width dynamically
+#define CHAR_WIDTH3 7.80 //78 // fix this please - determine the char-width dynamically
+
+namespace orxonox
+{
+    SetConsoleCommand(InGameConsole, openConsole, true);
+    SetConsoleCommand(InGameConsole, closeConsole, true);
+
+    using namespace Ogre;
+
+    float InGameConsole::REL_WIDTH = 0.8;
+    float InGameConsole::REL_HEIGHT = 0.4;
+    float InGameConsole::BLINK = 0.5;
+
+    /**
+        @brief Constructor: Creates and initializes the InGameConsole.
+    */
+    InGameConsole::InGameConsole() :
+        om_(0), consoleOverlay_(0), consoleOverlayContainer_(0),
+        consoleOverlayNoise_(0), consoleOverlayBorder_(0), consoleOverlayTextAreas_(0)
+    {
+        RegisterObject(InGameConsole);
+
+        this->bActive_ = false;
+        this->cursor_ = 0.0;
+        this->cursorSymbol_ = '|';
+        this->inputWindowStart_ = 0;
+        this->numLinesShifted_ = LINES - 1;
+
+        this->init();
+        this->setConfigValues();
+
+        Shell::getInstance().addOutputLevel(true);
+    }
+
+    /**
+        @brief Destructor: Destroys the TextAreas.
+    */
+    InGameConsole::~InGameConsole(void)
+    {
+        /*for (int i = 0; i < LINES; i++)
+            if (this->consoleOverlayTextAreas_[i])
+                om_->destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+
+        if (this->consoleOverlayTextAreas_)
+            delete[] this->consoleOverlayTextAreas_;*/
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of InGameConsole.
+    */
+    InGameConsole& InGameConsole::getInstance()
+    {
+        static InGameConsole instance;
+        return instance;
+    }
+
+    /**
+        @brief Sets the config values, describing the size of the console.
+    */
+    void InGameConsole::setConfigValues()
+    {
+        SetConfigValue(REL_WIDTH, 0.8);
+        SetConfigValue(REL_HEIGHT, 0.4);
+        SetConfigValue(BLINK, 0.5);
+    }
+
+    /**
+        @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()
+    {
+        /*std::string input = Shell::getInstance().getInput();
+        input.insert(Shell::getInstance().getCursorPosition(), 1, this->cursorSymbol_);
+        if (LINES > 0)
+            this->print(input, 0);*/
+        this->setCursorPosition(Shell::getInstance().getCursorPosition() - inputWindowStart_);
+    }
+
+    /**
+        @brief Called if the console gets closed.
+    */
+    void InGameConsole::exit()
+    {
+        this->deactivate();
+    }
+
+    /**
+        @brief Called once by constructor, initializes the InGameConsole.
+    */
+    void InGameConsole::init()
+    {
+        // for the beginning, don't scroll
+        this->scroll_ = 0;
+        this->cursor_ = 0;
+
+        // create overlay and elements
+        this->om_ = &Ogre::OverlayManager::getSingleton();
+
+        // create a container
+        this->consoleOverlayContainer_ = static_cast<OverlayContainer*>(this->om_->createOverlayElement("Panel", "InGameConsoleContainer"));
+        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+        this->consoleOverlayContainer_->setPosition((1 - InGameConsole::REL_WIDTH) / 2, 0);
+        this->consoleOverlayContainer_->setDimensions(InGameConsole::REL_WIDTH, InGameConsole::REL_HEIGHT);
+
+        // create BorderPanel
+        this->consoleOverlayBorder_ = static_cast<BorderPanelOverlayElement*>(this->om_->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+        // set parameters for border
+        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);
+
+        // create the text lines
+        this->consoleOverlayTextAreas_ = new TextAreaOverlayElement*[LINES];
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i] = static_cast<TextAreaOverlayElement*>(this->om_->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));
+            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+            this->consoleOverlayTextAreas_[i]->setFontName("Console");
+            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("");
+        }
+
+        // create noise
+        this->consoleOverlayNoise_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayNoise_->setPosition(5,0);
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoise");
+
+        // create cursor
+        this->consoleOverlayCursor_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleCursor"));
+        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayCursor_->setPosition(5,219);
+        this->consoleOverlayCursor_->setDimensions(1, 14);
+        this->consoleOverlayCursor_->setMaterialName("Orxonox/GreenDot");
+
+        this->consoleOverlay_ = this->om_->create("InGameConsoleConsole");
+        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+        //comment following line to disable noise
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+        for (int i = 0; i < LINES; i++)
+            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+
+        this->resize();
+
+        // move overlay "above" the top edge of the screen
+        // we take -1.2 because the border mkes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.2 * InGameConsole::REL_HEIGHT);
+        // show overlay
+        this->consoleOverlay_->show();
+
+        COUT(4) << "Info: InGameConsole initialized" << std::endl;
+    }
+
+    /**
+        @brief Resizes the console elements. Call if window size changes.
+    */
+    void InGameConsole::resize()
+    {
+        this->windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        this->windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        this->consoleOverlayBorder_->setWidth((int) this->windowW_* InGameConsole::REL_WIDTH);
+        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT);
+        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * InGameConsole::REL_WIDTH - 10);
+        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT - 5);
+
+        // now adjust the text lines...
+        this->desiredTextWidth_ = (int) (this->windowW_ * InGameConsole::REL_WIDTH) - 12;
+
+        if (LINES > 0)
+            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH3));
+        else
+            this->maxCharsPerLine_ = 10;
+
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * InGameConsole::REL_HEIGHT - 24 - 14*i);
+        }
+
+        this->linesChanged();
+        this->cursorChanged();
+    }
+
+    /**
+        @brief Used to control the actual scrolling and the cursor.
+    */
+    void InGameConsole::tick(float dt)
+    {
+        if (this->scroll_ != 0)
+        {
+            float top = this->consoleOverlayContainer_->getTop() + dt * this->scroll_;
+            this->consoleOverlayContainer_->setTop(top);
+
+            if (this->scroll_ < 0 && top <= -1.2 * InGameConsole::REL_HEIGHT)
+            {
+                // window has completely scrolled up
+                this->scroll_ = 0;
+                this->consoleOverlay_->hide();
+            }
+
+            if (this->scroll_ > 0 && top >= 0)
+            {
+                // window has completely scrolled down
+                this->scroll_ = 0;
+                this->consoleOverlayContainer_->setTop(0);
+            }
+        }
+
+        if (this->bActive_)
+        {
+            this->cursor_ += dt;
+            if (this->cursor_ >= InGameConsole::BLINK)
+            {
+                this->cursor_ = 0;
+                bShowCursor_ = !bShowCursor_;
+                if (bShowCursor_)
+                  this->consoleOverlayCursor_->show();
+                else
+                  this->consoleOverlayCursor_->hide();
+            }
+
+            /*if (this->cursor_ >= 2 * InGameConsole::BLINK)
+              this->cursor_ = 0;
+
+            if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|')
+            {
+                this->cursorSymbol_ = ' ';
+                this->cursorChanged();
+            }
+            else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ')
+            {
+                this->cursorSymbol_ = '|';
+                this->cursorChanged();
+            }*/
+
+            // this creates a flickering effect
+            this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1);
+        }
+    }
+
+    /**
+        @brief Shows the InGameConsole.
+    */
+    void InGameConsole::activate()
+    {
+        if (!this->bActive_)
+        {
+            this->bActive_ = true;
+            InputManager::setInputState(InputManager::IS_CONSOLE);
+            Shell::getInstance().registerListener(this);
+
+            this->resize();
+            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::setInputState(InputManager::IS_NORMAL);
+            Shell::getInstance().unregisterListener(this);
+
+            // scroll up
+            this->scroll_ = -1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+        @brief Activates the console.
+    */
+    void InGameConsole::openConsole()
+    {
+        InGameConsole::getInstance().activate();
+    }
+
+    /**
+        @brief Deactivates the console.
+    */
+    void InGameConsole::closeConsole()
+    {
+        InGameConsole::getInstance().deactivate();
+    }
+
+    /**
+        @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));
+        }
+    }
+
+    void InGameConsole::setCursorPosition(unsigned int pos)
+    {
+        static std::string char1 = "bdefgilpqtzCEGIJKNOPQT5[}äü";
+        static std::string char2 = "Z4";
+
+        if (pos > maxCharsPerLine_)
+          pos = maxCharsPerLine_;
+        else if (pos < 0)
+          pos = 0;
+
+        float width = 0;
+        for (unsigned int i = 0; i < pos && i < displayedText_.size(); ++i)
+        {
+            if (char1.find(displayedText_[i]) != std::string::npos)
+                width += CHAR_WIDTH1;
+            else if (char2.find(displayedText_[i]) != std::string::npos)
+                width += CHAR_WIDTH2;
+            else
+                width += CHAR_WIDTH3;
+        }
+        this->consoleOverlayCursor_->setPosition(width + 5, this->windowH_ * InGameConsole::REL_HEIGHT - 20);
+    }
+
+    /**
+        @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 Converts a string into an Ogre::UTFString.
+        @param s The string to convert
+        @return The converted string
+    */
+    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/network/src/orxonox/console/InGameConsole.h
===================================================================
--- /code/branches/network/src/orxonox/console/InGameConsole.h	(revision 1545)
+++ /code/branches/network/src/orxonox/console/InGameConsole.h	(revision 1545)
@@ -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:
+ *      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 "objects/Tickable.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener
+    {
+        public:
+            static InGameConsole& getInstance();
+
+            void setConfigValues();
+            void tick(float dt);
+
+            void resize();
+            static void openConsole();
+            static void closeConsole();
+
+        private:
+            InGameConsole();
+            InGameConsole(const InGameConsole& other);
+            ~InGameConsole();
+
+            void activate();
+            void deactivate();
+
+            virtual void linesChanged();
+            virtual void onlyLastLineChanged();
+            virtual void lineAdded();
+            virtual void inputChanged();
+            virtual void cursorChanged();
+            virtual void exit();
+
+            void init();
+            void shiftLines();
+            void colourLine(int colourcode, int index);
+            void setCursorPosition(unsigned int pos);
+            void print(const std::string& text, int index, bool alwaysShift = false);
+            static Ogre::UTFString convert2UTF(std::string s);
+
+            static float REL_WIDTH;
+            static float REL_HEIGHT;
+            static float BLINK;
+
+            bool bActive_;
+            int windowW_;
+            int windowH_;
+            int desiredTextWidth_;
+            unsigned int maxCharsPerLine_;
+            unsigned int numLinesShifted_;
+            int scroll_;
+            float cursor_;
+            unsigned int inputWindowStart_;
+            char cursorSymbol_;
+            bool bShowCursor_;
+            std::string displayedText_;
+            Ogre::OverlayManager* om_;
+            Ogre::Overlay* consoleOverlay_;
+            Ogre::OverlayContainer* consoleOverlayContainer_;
+            Ogre::PanelOverlayElement* consoleOverlayNoise_;
+            Ogre::PanelOverlayElement* consoleOverlayCursor_;
+            Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+            Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+    };
+}
+
+#endif /* _InGameConsole_H__ */
Index: /code/branches/network/src/orxonox/hud/BarOverlayElement.cc
===================================================================
--- /code/branches/network/src/orxonox/hud/BarOverlayElement.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/BarOverlayElement.cc	(revision 1545)
@@ -0,0 +1,127 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BarOverlayElement.h"
+#include <OgreOverlayManager.h>
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    using namespace Ogre;
+
+    BarOverlayElement::BarOverlayElement(const String& name):PanelOverlayElement(name){
+        name_ = name;
+    }
+
+    BarOverlayElement::~BarOverlayElement(){}
+
+    void BarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){
+        // init some values...
+        container_ = container;
+        om = &OverlayManager::getSingleton();
+        value_ = 0;
+        color_ = 2;
+        autoColor_ = true;
+        left2Right = false; 	// default is right to left progress
+        leftRel_ = leftRel;
+        topRel_ = topRel;
+        dimRel_ = dimRel;
+
+        // create background...
+        background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container"));
+        background_->show();
+        container_->addChild(background_);
+        background_->setMetricsMode(GMM_PIXELS);
+        background_->setMaterialName("Orxonox/BarBackground");
+
+        // calculate absolute coordinates...
+        resize();
+
+        show();
+        setMetricsMode(GMM_PIXELS);
+        setMaterialName("Orxonox/Green");
+        background_->addChild(this);
+    }
+
+    void BarOverlayElement::resize(){
+        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        // calculate new absolute coordinates...
+        left_ = (int) (leftRel_ * windowW_);
+        top_ = (int) (topRel_ * windowH_);
+        width_ = (int) (dimRel_ * windowW_);
+        height_ = (int) (0.1*width_);	// the texture has dimensions height:length = 1:10
+        // adapt background
+        background_->setPosition(left_, top_);
+        background_->setDimensions(width_, height_);
+        // adapt bar
+        setValue(value_);
+    }
+
+    void BarOverlayElement::setValue(float value){
+        value_ = value;
+        // set color, if nescessary
+        if(autoColor_){
+            if (value_>0.5) {setColor(BarOverlayElement::GREEN);}
+            else if (value_>0.25) {setColor(BarOverlayElement::YELLOW);}
+            else setColor(BarOverlayElement::RED);
+        }
+        // set value
+        if(left2Right){ // backward case
+            setPosition(0+width_-width_*value_, 0);
+            setDimensions(width_*value_,height_);
+        }else{          // default case
+            setPosition(0, 0);
+            setDimensions(width_*value_,height_);
+        }
+        if(value_ != 0) setTiling(value_, 1.0);
+    }
+
+    void BarOverlayElement::setColor(int color){
+        color_ = color;
+        switch(color){
+        case 0:
+            setMaterialName("Orxonox/Red");
+            break;
+        case 1:
+            setMaterialName("Orxonox/Yellow");
+            break;
+        case 2:
+            setMaterialName("Orxonox/Green");
+        }
+    }
+
+    float BarOverlayElement::getValue(){
+        return(value_);
+    }
+
+    int BarOverlayElement::getBarColor(){
+        return(color_);
+    }
+}
Index: /code/branches/network/src/orxonox/hud/BarOverlayElement.h
===================================================================
--- /code/branches/network/src/orxonox/hud/BarOverlayElement.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/BarOverlayElement.h	(revision 1545)
@@ -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:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+#ifndef _BarOverlayElement_H__
+#define _BarOverlayElement_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgrePanelOverlayElement.h>
+
+namespace orxonox
+{
+  class _OrxonoxExport BarOverlayElement : public Ogre::PanelOverlayElement
+  {
+    private:
+      bool autoColor_;                    // whether bar changes color automatically
+      float value_;                       // progress of bar
+      int color_;
+      int left_;
+      int top_;
+      int width_;
+      int height_;
+      int windowW_, windowH_;
+      Ogre::Real leftRel_;
+      Ogre::Real topRel_;
+      Ogre::Real dimRel_;
+      Ogre::OverlayManager* om;           // our overlay manager
+      Ogre::OverlayContainer* container_; // our parent container to attach to
+      Ogre::OverlayContainer* background_;
+      Ogre::String name_;
+
+    public:
+      bool left2Right;
+      static const int RED = 0;           // predefined colors
+      static const int YELLOW = 1;
+      static const int GREEN = 2;
+
+      BarOverlayElement(const Ogre::String& name);
+      virtual ~BarOverlayElement();
+      void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
+      void resize();
+      void setValue(float value);
+      void setColor(int color);
+      float getValue();
+      int getBarColor();
+    };
+}
+#endif /* _BarOverlayElement_H__ */
Index: /code/branches/network/src/orxonox/hud/HUD.cc
===================================================================
--- /code/branches/network/src/orxonox/hud/HUD.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/HUD.cc	(revision 1545)
@@ -0,0 +1,230 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUD.h"
+
+#include <string>
+#include <set>
+#include <OgreOverlay.h>
+#include <OgreOverlayContainer.h>
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+#include "core/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "objects/SpaceShip.h"
+#include "GraphicsEngine.h"
+#include "BarOverlayElement.h"
+#include "RadarObject.h"
+#include "RadarOverlayElement.h"
+#include "Navigation.h"
+#include "OverlayElementFactories.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
+    SetConsoleCommandShortcut(HUD, toggleFPS).setAccessLevel(AccessLevel::User);
+    SetConsoleCommandShortcut(HUD, toggleRenderTime).setAccessLevel(AccessLevel::User);
+
+    using namespace Ogre;
+
+    HUD::HUD(){
+        om = &Ogre::OverlayManager::getSingleton();
+        sm = GraphicsEngine::getSingleton().getSceneManager();
+        showFPS = true;
+        showRenderTime = true;
+
+        // create Factories
+        BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
+        om->addOverlayElementFactory(barOverlayElementFactory);
+        RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
+        om->addOverlayElementFactory(radarOverlayElementFactory);
+
+        orxonoxHUD = om->create("Orxonox/HUD");
+        container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container"));
+
+        // creating text to display fps
+        fpsText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "fpsText"));
+        fpsText->show();
+        fpsText->setMetricsMode(Ogre::GMM_PIXELS);
+        fpsText->setDimensions(0.001, 0.001);
+        fpsText->setPosition(10, 10);
+        fpsText->setFontName("Console");
+        fpsText->setCharHeight(20);
+        fpsText->setCaption("init");
+
+        // creating text to display render time ratio
+        rTRText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "rTRText"));
+        rTRText->show();
+        rTRText->setMetricsMode(Ogre::GMM_PIXELS);
+        rTRText->setDimensions(0.001, 0.001);
+        rTRText->setPosition(10, 30);
+        rTRText->setFontName("Console");
+        rTRText->setCharHeight(20);
+        rTRText->setCaption("init");
+
+        // create energy bar
+        energyBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyBar"));
+        energyBar->show();
+        // create speedo bar
+        speedoBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "speedoBar"));
+        speedoBar->show();
+        // create radar
+        radar = static_cast<RadarOverlayElement*>(om->createOverlayElement("Radar", "radar"));
+        radar->show();
+
+        // create Navigation
+        nav = new Navigation(container);
+
+        // set up screen-wide container
+        container->show();
+
+        orxonoxHUD->add2D(container);
+        orxonoxHUD->show();
+        container->setLeft(0.0);
+        container->setTop(0.0);
+        container->setWidth(1.0);
+        container->setHeight(1.0);
+        container->setMetricsMode(Ogre::GMM_RELATIVE);
+        container->addChild(fpsText);
+        container->addChild(rTRText);
+
+        energyBar->init(0.01, 0.94, 0.4, container);
+        energyBar->setValue(1);
+
+        speedoBar->init(0.01, 0.90, 0.4, container);
+
+        radar->init(0.5, 0.9, 0.2, container);
+        SceneNode* node;
+        node = sm->getRootSceneNode()->createChildSceneNode("tomato1", Vector3(2000.0, 0.0, 0.0));
+        addRadarObject(node);
+        node = sm->getRootSceneNode()->createChildSceneNode("tomato2", Vector3(0.0, 2000.0, 0.0));
+        addRadarObject(node);
+        node = sm->getRootSceneNode()->createChildSceneNode("tomato3", Vector3(0.0, 0.0, 2000.0));
+        addRadarObject(node);
+	node = sm->getRootSceneNode()->createChildSceneNode("station", Vector3(10000.0,16000.0,0.0));
+        addRadarObject(node, 3);
+    }
+
+    HUD::~HUD(){
+        //todo: clean up objects
+    }
+
+    void HUD::tick(float dt)
+    {
+        energyBar->resize();
+
+        if(!SpaceShip::getLocalShip())
+          return;
+        float v = SpaceShip::getLocalShip()->getVelocity().length();
+        float vmax = SpaceShip::getLocalShip()->getMaxSpeed();
+        speedoBar->setValue(v/vmax);
+        speedoBar->resize();
+
+        radar->resize();
+        radar->update();
+
+        nav->update();
+
+        setFPS();
+    }
+
+    void HUD::setRenderTimeRatio(float ratio)
+    {
+        if(showRenderTime){
+            rTRText->setCaption("Render time ratio: " + Ogre::StringConverter::toString(ratio));
+        }
+        else{
+            rTRText->setCaption("");
+            return;
+        }
+    }
+
+    void HUD::setFPS(){
+        if(showFPS){
+            float fps = GraphicsEngine::getSingleton().getAverageFPS();
+            fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps));
+        }
+        else{
+            fpsText->setCaption("");
+            return;
+        }
+    }
+
+    void HUD::addRadarObject(SceneNode* node, int colour){
+        RadarObject* obj = new RadarObject(container, node, colour);
+        roSet.insert(obj);
+//        // check if this is the first RadarObject to create
+//        if(firstRadarObject == NULL){
+//            firstRadarObject = new RadarObject(container, node, colour);
+//            lastRadarObject = firstRadarObject;
+//        }
+//        else{ // if not, append to list
+//            lastRadarObject->next = new RadarObject(container, node, colour);
+//            lastRadarObject = lastRadarObject->next;
+//        }
+    }
+
+    void HUD::removeRadarObject(Ogre::SceneNode* node){
+      COUT(3) << "blabla" << std::endl;
+        for(std::set<RadarObject*>::iterator it=roSet.begin(); it!=roSet.end(); it++){
+            if((*it)->getNode() == node) {
+                delete (*it);
+                roSet.erase(it);
+            }
+        }
+    }
+
+    /*static*/ HUD& HUD::getSingleton(){
+        static HUD theInstance;
+        return theInstance;
+    }
+
+    /*static*/ void HUD::setEnergy(float value){
+        HUD::getSingleton().energyBar->setValue(value);
+    }
+
+    /*static*/ void HUD::cycleNavigationFocus(){
+        HUD::getSingleton().nav->cycleFocus();
+    }
+
+    /*static*/ void HUD::toggleFPS(){
+        HUD::getSingleton().showFPS = !HUD::getSingleton().showFPS;
+    }
+
+    /*static*/ void HUD::toggleRenderTime(){
+        HUD::getSingleton().showRenderTime = !HUD::getSingleton().showRenderTime;
+    }
+}
+
+
+
+
+
+
Index: /code/branches/network/src/orxonox/hud/HUD.h
===================================================================
--- /code/branches/network/src/orxonox/hud/HUD.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/HUD.h	(revision 1545)
@@ -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
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+
+#ifndef _HUD_H__
+#define _HUD_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgreSceneNode.h>
+#include "objects/Tickable.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUD : public TickableReal
+    {
+      private:
+        HUD();
+        HUD(HUD& instance);
+        ~HUD();
+        Ogre::OverlayManager* om;
+        Ogre::SceneManager* sm;
+        Ogre::Overlay* orxonoxHUD;
+        Ogre::OverlayContainer* container;
+        Ogre::TextAreaOverlayElement* fpsText;
+        Ogre::TextAreaOverlayElement* rTRText;
+        BarOverlayElement* energyBar;
+        BarOverlayElement* speedoBar;
+        RadarOverlayElement* radar;
+        Navigation* nav;
+
+        bool showFPS;
+        bool showRenderTime;
+
+      public:
+        virtual void tick(float);
+        void addRadarObject(Ogre::SceneNode* node, int colour = 0);
+        void removeRadarObject(Ogre::SceneNode* node);
+        void setRenderTimeRatio(float ratio);
+        void setFPS();
+
+        std::set<RadarObject*> roSet;
+
+        static HUD* instance_s;
+        static HUD& getSingleton();
+        static void setEnergy(float value);
+        static void cycleNavigationFocus();
+        static void toggleFPS();
+        static void toggleRenderTime();
+    };
+}
+
+#endif /* _HUD_H__ */
Index: /code/branches/network/src/orxonox/hud/Navigation.cc
===================================================================
--- /code/branches/network/src/orxonox/hud/Navigation.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/Navigation.cc	(revision 1545)
@@ -0,0 +1,234 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Navigation.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+#include "GraphicsEngine.h"
+// TODO: remove the SpaceShip and CameraHandler dependencies
+#include "objects/SpaceShip.h"
+#include "objects/CameraHandler.h"
+#include "RadarObject.h"
+#include "RadarOverlayElement.h"
+#include "HUD.h"
+#include "core/Debug.h"
+
+namespace orxonox
+{
+    using namespace Ogre;
+
+    Navigation::Navigation(OverlayContainer* container){
+        container_ = container;
+        focus_ = NULL;
+        init();
+    }
+
+    Navigation::Navigation(OverlayContainer* container, RadarObject* focus){
+        container_ = container;
+        focus_ = focus;
+        init();
+    }
+
+    void Navigation::init(){
+        om = &OverlayManager::getSingleton();
+        navCam_ = NULL;
+        // create nav text
+        navText_ = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "navText"));
+        navText_->show();
+        navText_->setMetricsMode(Ogre::GMM_PIXELS);
+        navText_->setDimensions(0.001, 0.001);
+        navText_->setPosition(0.02, 0.02);
+        navText_->setFontName("Console");
+        navText_->setCharHeight(20);
+        navText_->setCaption("");
+        container_->addChild(navText_);
+
+
+        // create nav marker ...
+        navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker"));
+        navMarker_->setMetricsMode(GMM_PIXELS);
+        navMarker_->hide();
+        navText_->hide();
+        container_->addChild(navMarker_);
+    }
+
+    void Navigation::update(){
+        if(focus_ == NULL) return;
+        navCamPos_ = SpaceShip::getLocalShip()->getPosition();
+        currentDir_ = SpaceShip::getLocalShip()->getDir();
+        currentOrth_ = SpaceShip::getLocalShip()->getOrth();
+
+        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        updateMarker();
+    }
+
+    void Navigation::updateMarker(){
+        // set text
+        int dist = (int) getDist2Focus()/100;
+        navText_->setCaption(Ogre::StringConverter::toString(dist));
+
+        if(navCam_ == NULL) navCam_ = SpaceShip::getLocalShip()->getCamera()->cam_;
+        Vector3 pos = focus_->getPosition();
+        // transform to screen coordinates
+        pos = navCam_->getProjectionMatrix()*navCam_->getViewMatrix()*pos;
+        float xPosRel = 0.5*pos.x+0.5;
+        float yPosRel = 1-(0.5*pos.y+0.5);
+        int xPos = (int) (xPosRel*windowW_);
+        int yPos = (int) (yPosRel*windowH_);
+        int xFromCenter = xPos-windowW_/2;
+        int yFromCenter = yPos-windowH_/2;
+        // is object in view?
+        float radius = RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_);
+        bool isRight = (currentDir_.crossProduct(currentOrth_)).dotProduct(focus_->getPosition() - navCamPos_)>0;
+        bool isAbove = currentOrth_.dotProduct(focus_->getPosition() - navCamPos_)>0;
+        bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1);
+        // if object is behind us, it is out of view anyway:
+        if(!outOfView && radius>3.14/2) outOfView = true;
+
+        if(outOfView){
+            // object is not in view
+            navMarker_->setMaterialName("Orxonox/NavArrows");
+            navMarker_->setDimensions(16,16);
+            float phiUpperCorner = atan((float)(windowW_)/(float)(windowH_));
+            // from the angle we find out on which edge to draw the marker
+            // and which of the four arrows to take
+            float phiNav = atan((float) xFromCenter / (float) yFromCenter);
+
+            if(isAbove && isRight){
+                // top right quadrant
+                if(-phiNav<phiUpperCorner){
+                    //COUT(3) << "arrow up\n";
+                    navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0);
+                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
+                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getHeight());
+                }
+                else {
+                    //COUT(3) << "arrow right\n";
+                    navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
+                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
+                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
+                }
+            }
+            if(!isAbove && isRight){
+                // bottom right quadrant
+                if(phiNav<phiUpperCorner) {
+                    //COUT(3) << "arrow down\n";
+                    navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
+                }
+                else {
+                    //COUT(3) << "arrow right\n";
+                    navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
+                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
+                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
+                }
+            }
+            if(isAbove && !isRight){
+                // top left quadrant
+                if(phiNav<phiUpperCorner){
+                    //COUT(3) << "arrow up\n";
+                    navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0);
+                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
+                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getHeight());
+                }
+                else {
+                    //COUT(3) << "arrow left\n";
+                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
+                }
+            }
+            if(!isAbove && !isRight){
+                // bottom left quadrant
+                if(phiNav>-phiUpperCorner) {
+                    //COUT(3) << "arrow down\n";
+                    navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
+                }
+                else {
+                    //COUT(3) << "arrow left\n";
+                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth());
+                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
+                }
+            }
+        }
+        else{
+            // object is in view
+            navMarker_->setMaterialName("Orxonox/NavTDC");
+            navMarker_->setDimensions(24,24);
+            navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
+            navMarker_->setPosition(xPos-navMarker_->getWidth()/2, yPos-navMarker_->getHeight()/2);
+            navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2);
+        }
+    }
+
+    void Navigation::cycleFocus(){
+        if(focus_ == NULL){
+            it_ = HUD::getSingleton().roSet.begin();
+            focus_ = *it_;
+            ++it_;
+        }
+        else{
+            focus_->resetColour();
+            if(it_ != HUD::getSingleton().roSet.end()){
+                focus_ = *it_;
+                ++it_;
+            }
+            else focus_ = NULL;
+        }
+        if(focus_ == NULL){
+            navMarker_->hide();
+            navText_->hide();
+        }
+        else{
+            navMarker_->show();
+            navText_->show();
+            focus_->setColour(RadarObject::WHITE);
+        }
+    }
+
+    float Navigation::getDist2Focus(){
+        if(focus_ == NULL) return(0.0);
+        return((focus_->getPosition()-SpaceShip::getLocalShip()->getPosition()).length());
+    }
+}
Index: /code/branches/network/src/orxonox/hud/Navigation.h
===================================================================
--- /code/branches/network/src/orxonox/hud/Navigation.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/Navigation.h	(revision 1545)
@@ -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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Navigation_H__
+#define _Navigation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+#include "util/Math.h"
+
+namespace orxonox
+{
+
+    class _OrxonoxExport Navigation
+    {
+      private:
+        Ogre::OverlayManager* om;				            // our one and only overlay manager
+        Ogre::OverlayContainer* container_;
+        Ogre::PanelOverlayElement* navMarker_;      // the panel used to show the arrow
+        Ogre::TextAreaOverlayElement* navText_;     // displaying distance
+        Ogre::Camera* navCam_;
+        Vector3 navCamPos_;                         // position of ship
+        Vector3 currentDir_;
+        Vector3 currentOrth_;
+        std::set<RadarObject*>::iterator it_;
+        int windowW_, windowH_;
+        void init();
+        void updateMarker();
+
+      public:
+        Navigation(Ogre::OverlayContainer* container);
+        Navigation(Ogre::OverlayContainer* container, RadarObject* focus);
+        ~Navigation();
+        RadarObject* focus_;                        // next pointer of linked list
+
+        void update();
+        void cycleFocus();
+        float getDist2Focus();
+  };
+}
+
+#endif /* _Navigation_H__ */
Index: /code/branches/network/src/orxonox/hud/OverlayElementFactories.h
===================================================================
--- /code/branches/network/src/orxonox/hud/OverlayElementFactories.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/OverlayElementFactories.h	(revision 1545)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#ifndef _OverlayElementFactories_H__
+#define _OverlayElementFactories_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayElementFactory.h>
+
+#include "BarOverlayElement.h"
+#include "RadarOverlayElement.h"
+
+namespace orxonox{
+    class _OrxonoxExport BarOverlayElementFactory : public Ogre::OverlayElementFactory{
+      public:
+        Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
+            return new BarOverlayElement(instanceName);
+        }
+        const Ogre::String& getTypeName(void) const{
+            static Ogre::String name = "Bar";
+            return name;
+        }
+    };
+
+    class _OrxonoxExport RadarOverlayElementFactory : public Ogre::OverlayElementFactory{
+      public:
+        Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
+            return new RadarOverlayElement(instanceName);
+        }
+        const Ogre::String& getTypeName(void) const{
+            static Ogre::String name = "Radar";
+            return name;
+        }
+    };
+}
+
+#endif /* _OverlayElementFactories_H__ */
Index: /code/branches/network/src/orxonox/hud/RadarObject.cc
===================================================================
--- /code/branches/network/src/orxonox/hud/RadarObject.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/RadarObject.cc	(revision 1545)
@@ -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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarObject.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    using namespace Ogre;
+
+    int RadarObject::count = 0;		// initialize static variable
+
+    RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){
+        container_ = container;
+        node_ = node;
+        colour_ = colour;
+        om = &OverlayManager::getSingleton();
+        panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel",
+            "Object"+StringConverter::toString(count)));
+        setColour(colour_);
+        panel_->setDimensions(3,3);
+        panel_->setMetricsMode(Ogre::GMM_PIXELS);
+        panel_->show();
+        index_ = count;
+        count++;
+        container_->addChild(panel_);
+    }
+
+    RadarObject::~RadarObject(){
+        delete panel_;
+    }
+
+    void RadarObject::setColour(int colour){
+        switch(colour){
+        case RED: panel_->setMaterialName("Orxonox/RedDot"); break;
+        case YELLOW: panel_->setMaterialName("Orxonox/YellowDot"); break;
+        case GREEN: panel_->setMaterialName("Orxonox/GreenDot"); break;
+        case BLUE: panel_->setMaterialName("Orxonox/BlueDot"); break;
+        case WHITE: panel_->setMaterialName("Orxonox/WhiteDot"); break;
+        default: panel_->setMaterialName("Orxonox/RedDot"); break;
+        }
+    }
+
+    void RadarObject::resetColour(){
+        setColour(colour_);
+    }
+
+    Vector3 RadarObject::getPosition(){
+        return node_->getPosition();
+    }
+
+    SceneNode* RadarObject::getNode(){
+        return node_;
+    }
+}
+
Index: /code/branches/network/src/orxonox/hud/RadarObject.h
===================================================================
--- /code/branches/network/src/orxonox/hud/RadarObject.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/RadarObject.h	(revision 1545)
@@ -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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _RadarObject_H__
+#define _RadarObject_H__
+
+#include <OgrePrerequisites.h>
+#include <OgreSceneNode.h>
+#include <OgrePanelOverlayElement.h>
+#include "OrxonoxPrereqs.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarObject
+    {
+      private:
+        Ogre::OverlayManager* om;				// our one and only overlay manager
+        Ogre::SceneNode* node_;					// node of object
+        int colour_;
+
+      public:
+        RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, int colour = 0);
+        ~RadarObject();
+        void setColour(int colour);
+        void resetColour();
+        Vector3 getPosition();
+        Ogre::SceneNode* getNode();
+
+        bool right_;
+        int index_;                             // index number of object
+        Ogre::OverlayContainer* container_;
+        Ogre::PanelOverlayElement* panel_;		// the panel used to show the dot
+
+        static int count;
+        static const int RED = 0;
+        static const int YELLOW = 1;
+        static const int GREEN = 2;
+        static const int BLUE = 3;
+        static const int WHITE = 99;            // used if object got nav focus
+  };
+}
+
+#endif /* _RadarObject_H__ */
Index: /code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
===================================================================
--- /code/branches/network/src/orxonox/hud/RadarOverlayElement.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/RadarOverlayElement.cc	(revision 1545)
@@ -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:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarOverlayElement.h"
+
+#include <string>
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+#include "GraphicsEngine.h"
+#include "core/ConsoleCommand.h"
+#include "objects/Tickable.h"
+#include "objects/SpaceShip.h"
+#include "RadarObject.h"
+#include "HUD.h"
+
+namespace orxonox
+{
+    using namespace Ogre;
+
+    RadarOverlayElement::RadarOverlayElement(const String& name):PanelOverlayElement(name){
+    }
+
+    RadarOverlayElement::~RadarOverlayElement(){
+    }
+
+    void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){
+        // some initial data
+        om = &OverlayManager::getSingleton();
+        dimRel_ = dimRel;
+        leftRel_ = leftRel;
+        topRel_ = topRel;
+        container_ = container;
+
+        setMetricsMode(GMM_PIXELS);
+        setMaterialName("Orxonox/Radar");
+        resize();
+
+        container_->addChild(this);
+    }
+
+    void RadarOverlayElement::resize() {
+        // if window is resized, we must adapt these...
+        windowW_ = GraphicsEngine::getSingleton().getWindowWidth();
+        windowH_ = GraphicsEngine::getSingleton().getWindowHeight();
+        dim_ = (int) (dimRel_*windowH_);
+        left_ = (int) (leftRel_*windowW_-dim_/2);
+        top_ = (int) (topRel_*windowH_-dim_/2);
+        setPosition(left_, top_);
+        setDimensions(dim_,dim_);
+    }
+
+    void RadarOverlayElement::update() {
+        shipPos_ = SpaceShip::getLocalShip()->getPosition();
+        currentDir_ = SpaceShip::getLocalShip()->getDir();
+        currentOrth_ = SpaceShip::getLocalShip()->getOrth();
+        // iterate through all RadarObjects
+        for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){
+        // calc position on radar...
+            float radius = calcRadius(shipPos_, currentDir_, currentOrth_, (*it));
+            float phi = calcPhi(shipPos_, currentDir_, currentOrth_, (*it));
+            bool right = calcRight(shipPos_, currentDir_, currentOrth_, (*it));
+
+            // set size to fit distance...
+            float d = ((*it)->getPosition()-shipPos_).length();
+            if(d<10000) (*it)->panel_->setDimensions(4,4);
+            else if(d<20000) (*it)->panel_->setDimensions(3,3);
+            else (*it)->panel_->setDimensions(2,2);
+
+            if (right){
+                (*it)->panel_->setPosition(sin(phi)*radius/
+                    3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2);
+            }
+            else {
+                (*it)->panel_->setPosition(-sin(phi)*radius/
+                    3.5*dim_/2+dim_/2+left_-2,-cos(phi)*radius/3.5*dim_/2+dim_/2+top_-2);
+            }
+        }
+    }
+
+    void RadarOverlayElement::listObjects(){
+        int i = 0;
+        COUT(3) << "List of RadarObjects:\n";
+        // iterate through all Radar Objects
+        for(std::set<RadarObject*>::iterator it=HUD::getSingleton().roSet.begin(); it!=HUD::getSingleton().roSet.end(); it++){
+            COUT(3) << i++ << ": " << (*it)->getPosition() << std::endl;
+        }
+    }
+
+    float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){
+        return(acos((dir.dotProduct(obj->getPosition() - pos))/
+        ((obj->getPosition() - pos).length()*dir.length())));
+    }
+
+    float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){
+        // project difference vector on our plane...
+        Vector3 proj = Plane(dir, pos).projectVector(obj->getPosition() - pos);
+        // ...and find out the angle
+        return(acos((orth.dotProduct(proj))/
+              (orth.length()*proj.length())));
+    }
+
+    bool RadarOverlayElement::calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){
+        if((dir.crossProduct(orth)).dotProduct(obj->getPosition() - pos) > 0)
+            return true;
+        else return false;
+    }
+}
Index: /code/branches/network/src/orxonox/hud/RadarOverlayElement.h
===================================================================
--- /code/branches/network/src/orxonox/hud/RadarOverlayElement.h	(revision 1545)
+++ /code/branches/network/src/orxonox/hud/RadarOverlayElement.h	(revision 1545)
@@ -0,0 +1,67 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#ifndef _RadarOverlayElement_H__
+#define _RadarOverlayElement_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgrePanelOverlayElement.h>
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement
+    {
+      private:
+        Ogre::OverlayManager* om;               // our one and only overlay manager
+        Ogre::OverlayContainer* container_;     // pointer to the container we're in
+        Vector3 currentDir_;
+        Vector3 currentOrth_;
+        Vector3 shipPos_;                       // position of ship
+
+        Ogre::Real leftRel_, topRel_, dimRel_;  // relative position/dimension
+        int left_, top_, dim_;                  // absolute position/dimension
+        int windowW_, windowH_;             	  // absolute window dimensions
+
+      public:
+        RadarOverlayElement(const Ogre::String& name);
+        ~RadarOverlayElement();
+        void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
+        void resize();
+        void update();
+        void listObjects();
+
+        static float calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj);
+        static float calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj);
+        static bool calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj);
+  };
+}
+
+#endif /* _RadarOverlayElement_H__ */
Index: /code/branches/network/src/orxonox/objects/Ambient.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Ambient.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Ambient.cc	(revision 1545)
@@ -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:
+ *      ...
+ *   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/Convert.h"
+#include "util/Math.h"
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline);
+
+    CreateFactory(Ambient);
+
+    Ambient* Ambient::instance_s;
+
+    Ambient::Ambient()
+    {
+        RegisterObject(Ambient);
+        Ambient::instance_s = this;
+        registerAllVariables();
+    }
+
+    Ambient::~Ambient()
+    {
+    }
+
+    bool Ambient::create(){
+      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
+      return Synchronisable::create();
+    }
+    
+    void Ambient::registerAllVariables(){
+      registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
+      
+    }
+    
+    void Ambient::loadParams(TiXmlElement* xmlElem)
+    {
+    	if (xmlElem->Attribute("colourvalue"))
+    	{
+        SubString colourvalues(xmlElem->Attribute("colourvalue"), ',');
+
+	    	float r, g, b;
+        convertValue<std::string, float>(&r, colourvalues[0]);
+        convertValue<std::string, float>(&g, colourvalues[1]);
+        convertValue<std::string, float>(&b, colourvalues[2]);
+
+	    	this->setAmbientLight(ColourValue(r, g, b));
+
+	    	COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b  << std::endl << std::endl;
+    	}
+   }
+
+   void Ambient::setAmbientLight(const ColourValue& colour)
+   {
+    	GraphicsEngine::getSingleton().getSceneManager()->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)
+    {
+        BaseObject::XMLPort(xmlelement, mode);
+
+        XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
+        create();
+    }
+}
Index: /code/branches/network/src/orxonox/objects/Ambient.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Ambient.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Ambient.h	(revision 1545)
@@ -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 _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, network::Synchronisable
+    {
+        public:
+            Ambient();
+            virtual ~Ambient();
+
+            void loadParams(TiXmlElement* xmlElem);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void setAmbientLight(const ColourValue& colour);
+            virtual bool create();
+            void registerAllVariables();
+
+            static void setAmbientLightTest(const ColourValue& colour)
+                { Ambient::instance_s->setAmbientLight(colour); }
+
+        private:
+            static Ambient* instance_s;
+            ColourValue ambientLight_;
+
+    };
+}
+
+#endif /* _Ambient_H__ */
Index: /code/branches/network/src/orxonox/objects/Camera.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Camera.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Camera.cc	(revision 1545)
@@ -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:
+ *      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/Convert.h"
+#include "util/Math.h"
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+
+  Camera::Camera(Ogre::SceneNode* node)
+  {
+    this->bHasFocus_ = false;
+    this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
+    if( node != NULL )
+      this->setPositionNode(node);
+  }
+
+  Camera::~Camera()
+  {
+    CameraHandler::getInstance()->releaseFocus(this);
+    GraphicsEngine::getSingleton().getSceneManager()->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/network/src/orxonox/objects/Camera.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Camera.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Camera.h	(revision 1545)
@@ -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/network/src/orxonox/objects/CameraHandler.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/CameraHandler.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/CameraHandler.cc	(revision 1545)
@@ -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:
+ *      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::getSingleton().getSceneManager()->createCamera("Cam");
+    GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
+    /*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/network/src/orxonox/objects/CameraHandler.h
===================================================================
--- /code/branches/network/src/orxonox/objects/CameraHandler.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/CameraHandler.h	(revision 1545)
@@ -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/network/src/orxonox/objects/Explosion.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Explosion.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Explosion.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Explosion.h"
+
+#include <OgreParticleSystem.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+#include "particle/ParticleInterface.h"
+
+namespace orxonox
+{
+    CreateFactory(Explosion);
+
+    Explosion::Explosion(WorldEntity* owner) :
+      lifetime_(0.4),
+      particle_(0)
+    {
+        RegisterObject(Explosion);
+
+        if (owner)
+        {
+            this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Explosion::destroyObject)));
+
+            Vector3 position = owner->getNode()->getWorldPosition();
+
+            this->particle_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(), "explosion" + this->getName(), "Orxonox/treibwerk");
+            this->particle_->getParticleSystem()->setParameter("local_space", "true");
+            this->particle_->newEmitter();
+            this->particle_->setPositionOfEmitter(0, Vector3::ZERO);
+            this->particle_->setPositionOfEmitter(1, Vector3::ZERO);
+            this->particle_->setColour(ColourValue(1.0, 0.8, 0.2));
+
+            this->setPosition(position);
+            this->scale(2);
+
+            this->particle_->addToSceneNode(this->getNode());
+        }
+    }
+
+    Explosion::~Explosion()
+    {
+        if (this->particle_)
+        {
+            this->particle_->detachFromSceneNode();
+            delete this->particle_;
+        }
+    };
+    
+    /*bool Explosion::create(){
+      if(!WorldEntity::create())
+        return false;
+      classID=this->getIdentifier()->getNetworkID();
+    }*/
+
+    void Explosion::destroyObject()
+    {
+        delete this;
+    }
+}
Index: /code/branches/network/src/orxonox/objects/Explosion.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Explosion.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Explosion.h	(revision 1545)
@@ -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 _Explosion_H__
+#define _Explosion_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "../tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Explosion : public WorldEntity
+    {
+        public:
+            Explosion(WorldEntity* owner = 0);
+            virtual ~Explosion();
+            void destroyObject();
+            virtual bool create(){return WorldEntity::create();}
+
+        private:
+            Timer<Explosion> destroyTimer_;
+            float lifetime_;
+            ParticleInterface* particle_;
+    };
+}
+
+#endif /* _Explosion_H__ */
Index: /code/branches/network/src/orxonox/objects/Model.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Model.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Model.cc	(revision 1545)
@@ -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:
+ *      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()
+    {
+    }
+
+    /**
+        @brief XML loading and saving.
+    @p
+    aram xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        WorldEntity::XMLPort(xmlelement, mode);
+
+        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
+
+        Model::create();
+    }
+
+    void Model::setMesh(const std::string& meshname)
+    {
+        this->meshSrc_ = meshname;
+    }
+
+    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;
+      }
+      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);
+    }
+}
Index: /code/branches/network/src/orxonox/objects/Model.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Model.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Model.h	(revision 1545)
@@ -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:
+ *      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);
+            void setMesh(const std::string& meshname);
+            virtual bool create();
+
+        protected:
+            void registerAllVariables();
+
+        private:
+            std::string meshSrc_;
+            Mesh mesh_;
+    };
+}
+
+#endif /* _Model_H__ */
Index: /code/branches/network/src/orxonox/objects/NPC.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/NPC.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/NPC.cc	(revision 1545)
@@ -0,0 +1,180 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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"
+
+namespace orxonox {
+
+  CreateFactory(NPC);
+
+  NPC::NPC() :
+    movable_(true)
+  {
+    RegisterObject(NPC);
+    registerAllVariables();
+  }
+
+  NPC::~NPC()
+  {
+  }
+
+  void NPC::loadParams(TiXmlElement* xmlElem)
+  {
+    Model::loadParams(xmlElem);
+  }
+
+  /**
+   * 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(Iterator<WorldEntity> it = ObjectList<WorldEntity>::start(); 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(Iterator<NPC> it = ObjectList<NPC>::start(); 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(Iterator<NPC> it = ObjectList<NPC>::start(); 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/network/src/orxonox/objects/NPC.h
===================================================================
--- /code/branches/network/src/orxonox/objects/NPC.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/NPC.h	(revision 1545)
@@ -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:
+ *      ...
+ *   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 loadParams(TiXmlElement* xmlElem);
+      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/network/src/orxonox/objects/Projectile.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Projectile.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Projectile.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Projectile.h"
+
+#include <OgreBillboard.h>
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "core/ConfigValueIncludes.h"
+
+#include "SpaceShip.h"
+#include "Explosion.h"
+#include "Model.h"
+
+namespace orxonox
+{
+    CreateFactory(Projectile);
+
+    float Projectile::speed_ = 0;
+
+    Projectile::Projectile(SpaceShip* owner) :
+      owner_(owner)
+    {
+        RegisterObject(Projectile);
+
+        this->setConfigValues();
+
+        this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
+        this->attachObject(this->billboard_.getBillboardSet());
+        this->scale(0.5);
+
+        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(Vector3(1, 0, 0) * this->speed_);
+        }
+
+        this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
+//        COUT(3) << this->classID << std::endl;
+    }
+
+    Projectile::~Projectile()
+    {
+    }
+
+    void Projectile::setConfigValues()
+    {
+        SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive");
+        SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second");
+
+        this->setVelocity(Vector3(1, 0, 0) * this->speed_);
+    }
+
+    void Projectile::tick(float dt)
+    {
+        WorldEntity::tick(dt);
+
+        float radius;
+        for (Iterator<Model> it = ObjectList<Model>::start(); it; ++it)
+        {
+            if ((*it) != this->owner_)
+            {
+                radius = it->getScale().x * 3.0;
+
+                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
+                {
+                    Explosion *exp = new Explosion(this);
+                    exp->create();
+                    delete this;
+                    return;
+                }
+            }
+        }
+    }
+
+    void Projectile::destroyObject()
+    {
+        delete this;
+    }
+
+    void Projectile::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+    }
+}
Index: /code/branches/network/src/orxonox/objects/Projectile.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Projectile.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Projectile.h	(revision 1545)
@@ -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 _Projectile_H__
+#define _Projectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "../tools/BillboardSet.h"
+#include "../tools/Timer.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Projectile : public WorldEntity
+    {
+        public:
+            Projectile(SpaceShip* owner = 0);
+            virtual ~Projectile();
+            void setConfigValues();
+            void destroyObject();
+            virtual void tick(float dt);
+            virtual bool create(){return WorldEntity::create();}
+            void setColour(const ColourValue& colour);
+
+            static float getSpeed()
+                { return Projectile::speed_; }
+
+        protected:
+            SpaceShip* owner_;
+
+        private:
+            BillboardSet billboard_;
+            static float speed_;
+            float lifetime_;
+            Timer<Projectile> destroyTimer_;
+    };
+}
+
+#endif /* _Projectile_H__ */
Index: /code/branches/network/src/orxonox/objects/RotatingProjectile.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/RotatingProjectile.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/RotatingProjectile.cc	(revision 1545)
@@ -0,0 +1,82 @@
+/*
+ *   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) : Projectile(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));
+
+        this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
+        this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
+    }
+
+    void RotatingProjectile::tick(float dt)
+    {
+        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));
+
+        Projectile::tick(dt);
+    }
+}
Index: /code/branches/network/src/orxonox/objects/RotatingProjectile.h
===================================================================
--- /code/branches/network/src/orxonox/objects/RotatingProjectile.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/RotatingProjectile.h	(revision 1545)
@@ -0,0 +1,29 @@
+#ifndef _RotatingProjectile_H__
+#define _RotatingProjectile_H__
+
+#include "../OrxonoxPrereqs.h"
+#include "util/Math.h"
+#include "Projectile.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RotatingProjectile : public Projectile/*, public network::Synchronisable*/
+    {
+        public:
+            RotatingProjectile(SpaceShip* owner = 0);
+            virtual ~RotatingProjectile();
+            void setConfigValues();
+            virtual void tick(float dt);
+            virtual bool create(){return Projectile::create();}
+
+        private:
+            ColourValue colour_;
+            BillboardSet rotatingBillboard1_;
+            BillboardSet rotatingBillboard2_;
+            Ogre::SceneNode* rotatingNode1_;
+            Ogre::SceneNode* rotatingNode2_;
+            float time_;
+    };
+}
+
+#endif /* _RotatingProjectile_H__ */
Index: /code/branches/network/src/orxonox/objects/Skybox.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Skybox.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Skybox.cc	(revision 1545)
@@ -0,0 +1,99 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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/Debug.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(Skybox);
+
+    Skybox::Skybox()
+    {
+        RegisterObject(Skybox);
+        registerAllVariables();
+    }
+
+    Skybox::~Skybox()
+    {
+    }
+
+    void Skybox::loadParams(TiXmlElement* xmlElem)
+    {
+    	if (xmlElem->Attribute("src"))
+    	{
+    		skyboxSrc_ = xmlElem->Attribute("src");
+        this->create();
+
+	    	COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
+    	}
+   }
+
+   void Skybox::setSkybox(const std::string& skyboxname)
+   {
+    	GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);
+   }
+
+   void Skybox::setSkyboxSrc(const std::string& src){
+     skyboxSrc_ = src;
+   }
+   
+    /**
+        @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)
+    {
+        BaseObject::XMLPort(xmlelement, mode);
+
+        XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
+        create();
+    }
+    
+    bool Skybox::create(){
+      this->setSkybox(skyboxSrc_);
+      return Synchronisable::create();
+    }
+    
+    void Skybox::registerAllVariables(){
+      registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
+    }
+    
+}
Index: /code/branches/network/src/orxonox/objects/Skybox.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Skybox.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Skybox.h	(revision 1545)
@@ -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:
+ *      ...
+ *   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();
+
+            void loadParams(TiXmlElement* xmlElem);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void setSkybox(const std::string& skyboxname);
+            
+            virtual bool create();
+            void registerAllVariables();
+            void setSkyboxSrc(const std::string &src);
+
+        private:
+            std::string skyboxSrc_;
+
+
+    };
+}
+
+#endif /* _Skybox_H__ */
Index: /code/branches/network/src/orxonox/objects/SpaceShip.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1545)
@@ -0,0 +1,536 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "CameraHandler.h"
+#include "util/Convert.h"
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Debug.h"
+#include "GraphicsEngine.h"
+#include "core/input/InputManager.h"
+#include "particle/ParticleInterface.h"
+#include "Projectile.h"
+#include "RotatingProjectile.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+#include "network/Client.h"
+#include "hud/HUD.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug);
+    SetConsoleCommand(SpaceShip, whereAmI, true).setAccessLevel(AccessLevel::User);
+    SetConsoleCommand(SpaceShip, moveLongitudinal, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveLateral, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveYaw, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, movePitch, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveRoll, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, fire, true).setAccessLevel(AccessLevel::User).setKeybindMode(KeybindMode::OnHold);
+    SetConsoleCommandGeneric(test1, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug);
+    SetConsoleCommandGeneric(test2, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug);
+    SetConsoleCommandGeneric(test3, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug);
+
+    CreateFactory(SpaceShip);
+
+    SpaceShip* SpaceShip::instance_s;
+
+    
+    SpaceShip *SpaceShip::getLocalShip(){
+      Iterator<SpaceShip> it;
+      for(it = ObjectList<SpaceShip>::start(); it; ++it){
+        if( (it)->myShip_ )
+          return *it;
+      }
+      return NULL;
+    }
+
+    SpaceShip::SpaceShip() :
+      //testvector_(0,0,0),
+      //bInvertYAxis_(false),
+      setMouseEventCallback_(false),
+      bLMousePressed_(false),
+      bRMousePressed_(false),
+      camNode_(0),
+      cam_(0),
+      camName_("CamNode"),
+      tt_(0),
+      redNode_(0),
+      greenNode_(0),
+      blinkTime_(0.0f),
+      chNearNode_(0),
+      chFarNode_(0),
+      timeToReload_(0.0f),
+      //reloadTime_(0.0f),
+      maxSideAndBackSpeed_(0.0f),
+      maxSpeed_(0.0f),
+      maxRotation_(0.0f),
+      translationAcceleration_(0.0f),
+      rotationAcceleration_(0.0f),
+      translationDamping_(0.0f),
+      rotationDamping_(0.0f),
+      maxRotationRadian_(0),
+      rotationAccelerationRadian_(0),
+      rotationDampingRadian_(0),
+      zeroRadian_(0),
+      mouseXRotation_(0),
+      mouseYRotation_(0),
+      mouseX_(0.0f),
+      mouseY_(0.0f),
+      emitterRate_(0.0f),
+      myShip_(false),
+      teamNr_(0),
+      health_(100)
+    {
+        RegisterObject(SpaceShip);
+        this->registerAllVariables();
+
+        SpaceShip::instance_s = this;
+
+        this->setConfigValues();
+
+        initialDir_ = Vector3(1.0, 0.0, 0.0);
+        currentDir_ = initialDir_;
+        initialOrth_ = Vector3(0.0, 0.0, 1.0);
+        currentOrth_ = initialOrth_;
+
+        this->camName_ = this->getName() + "CamNode";
+
+        this->setRotationAxis(1, 0, 0);
+        this->setStatic(false);
+
+        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
+    }
+
+    SpaceShip::~SpaceShip()
+    {
+        if (this->tt_)
+            delete this->tt_;
+        if(setMouseEventCallback_)
+          InputManager::removeMouseHandler("SpaceShip");
+        if (this->cam_)
+          delete this->cam_;
+        if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL)
+          //remove the radar object
+          HUD::getSingleton().removeRadarObject(this->getNode());
+    }
+
+    bool SpaceShip::create(){
+      if(!myShip_){
+        if(network::Client::getSingleton() && objectID == network::Client::getSingleton()->getShipID())
+          myShip_=true;
+        else
+          HUD::getSingleton().addRadarObject(this->getNode(), 3);
+      }
+      if(Model::create())
+        this->init();
+      else
+        return false;
+      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()
+    {
+        // START CREATING THRUSTER
+        this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
+        this->tt_->getParticleSystem()->setParameter("local_space","true");
+        this->tt_->newEmitter();
+/*
+        this->tt_->setDirection(Vector3(0,0,1));
+        this->tt_->setPositionOfEmitter(0, Vector3(20,-1,-15));
+        this->tt_->setPositionOfEmitter(1, Vector3(-20,-1,-15));
+*/
+        this->tt_->setDirection(Vector3(-1,0,0));
+        this->tt_->setPositionOfEmitter(0, Vector3(-15,20,-1));
+        this->tt_->setPositionOfEmitter(1, Vector3(-15,-20,-1));
+        this->tt_->setVelocity(50);
+
+        emitterRate_ = tt_->getRate();
+
+        Ogre::SceneNode* node2 = this->getNode()->createChildSceneNode(this->getName() + "particle2");
+        node2->setInheritScale(false);
+        tt_->addToSceneNode(node2);
+        // END CREATING THRUSTER
+
+        // 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
+
+        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);
+        }
+
+        createCamera();
+        // END of testing crosshair
+    }
+
+    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::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::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
+        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(-50,0,10));
+//      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,-1,0));
+      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(1,0,0));
+      camNode_->setOrientation(q2*q1);
+      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
+        this->setBacksync(true);
+        CameraHandler::getInstance()->requestFocus(cam_);
+      }
+
+    }
+
+    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)
+    {
+        Model::XMLPort(xmlelement, mode);
+
+        XMLPortParamLoadOnly(SpaceShip, "camera", setCamera, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "maxSpeed", setMaxSpeed, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "maxRotation", setMaxRotation, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "transAcc", setTransAcc, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "rotAcc", setRotAcc, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
+        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
+        myShip_=true; // TODO: this is only a hack
+
+        SpaceShip::create();
+        if (this->isExactlyA(Class(SpaceShip)))
+            getFocus();
+    }
+
+    int sgn(float x)
+    {
+        if (x >= 0)
+            return 1;
+        else
+            return -1;
+    }
+
+    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);
+    }
+
+    Vector3 SpaceShip::getDir() {
+        return currentDir_;
+    }
+
+    Vector3 SpaceShip::getOrth(){
+        return currentOrth_;
+    }
+
+    float SpaceShip::getMaxSpeed() { return maxSpeed_; }
+
+    void SpaceShip::tick(float dt)
+    {
+        currentDir_ = getOrientation()*initialDir_;
+		currentOrth_ = getOrientation()*initialOrth_;
+
+        if (this->cam_)
+            this->cam_->tick(dt);
+
+        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)
+        {
+
+            Projectile *p;
+            if (this->isExactlyA(Class(SpaceShip)))
+                p = new RotatingProjectile(this);
+            else
+                p = new Projectile(this);
+            p->setColour(this->getProjectileColour());
+            p->create();
+            if(p->classID==0)
+              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
+
+            p->setBacksync(true);
+            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;
+            }
+        }
+
+
+        WorldEntity::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->tt_->setRate(emitterRate_);
+        else
+            this->tt_->setRate(0);
+
+        if( myShip_ )
+        {
+          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;
+        }/*else
+          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
+    }
+
+    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/network/src/orxonox/objects/SpaceShip.h
===================================================================
--- /code/branches/network/src/orxonox/objects/SpaceShip.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/SpaceShip.h	(revision 1545)
@@ -0,0 +1,167 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport SpaceShip : public Model
+    {
+        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);
+
+            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();
+
+            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();
+
+            float getMaxSpeed();
+            Vector3 getDir();
+            Vector3 getOrth();
+            Camera* getCamera();
+
+            int getTeamNr() const
+                { return this->teamNr_; }
+            int 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 setMouseEventCallback_;
+            bool bLMousePressed_;
+            bool bRMousePressed_;
+
+            Ogre::SceneNode* camNode_;
+            Camera* cam_;
+            std::string camName_;
+
+
+            ParticleInterface* tt_;
+
+            BillboardSet redBillboard_;
+            BillboardSet greenBillboard_;
+            Ogre::SceneNode* redNode_;
+            Ogre::SceneNode* greenNode_;
+            float blinkTime_;
+
+            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_;
+
+            float emitterRate_;
+
+        protected:
+            bool myShip_;
+
+            int teamNr_;
+            int health_;
+
+            static SpaceShip* instance_s;
+    };
+}
+
+#endif /* _SpaceShip_H__ */
Index: /code/branches/network/src/orxonox/objects/SpaceShipAI.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/SpaceShipAI.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/SpaceShipAI.cc	(revision 1545)
@@ -0,0 +1,293 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "core/Executor.h"
+#include "core/ConsoleCommand.h"
+#include "core/XMLPort.h"
+
+#define ACTION_INTERVAL 1.0f
+
+namespace orxonox
+{
+    SetConsoleCommand(SpaceShipAI, createEnemy, true).setDefaultValue(0, 1);
+    SetConsoleCommand(SpaceShipAI, killEnemies, true).setDefaultValue(0, 0);
+
+    CreateFactory(SpaceShipAI);
+
+    SpaceShipAI::SpaceShipAI()
+    {
+        RegisterObject(SpaceShipAI);
+
+        this->alive_ = true;
+        this->setPosition(Vector3(rnd(-1000, 1000), rnd(-1000, 1000), rnd(-1000, 0000)));
+        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);
+    }
+
+    void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SpaceShip::XMLPort(xmlelement, mode);
+        myShip_=true;
+
+        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->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);
+        }
+    }
+
+    void SpaceShipAI::killEnemies(int num)
+    {
+        int i = 0;
+        for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; )
+        {
+            delete *(it++);
+            ++i;
+            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);
+//std::cout << "search enemy: " << random << std::endl;
+        if (random < 20 && (!this->target_))
+        {
+            this->searchNewTarget();
+        }
+
+        // forget enemy
+        random = rnd(maxrand);
+//std::cout << "forget enemy: " << random << std::endl;
+        if (random < 5 && (this->target_))
+        {
+            this->forgetTarget();
+        }
+
+        // next enemy
+        random = rnd(maxrand);
+//std::cout << "next enemy: " << random << std::endl;
+        if (random < 10 && (this->target_))
+        {
+            this->searchNewTarget();
+        }
+
+        // fly somewhere
+        random = rnd(maxrand);
+//std::cout << "fly somewhere: " << random << std::endl;
+        if (random < 40 && (!this->bHasTargetPosition_ && !this->target_))
+        {
+            this->searchNewTargetPosition();
+        }
+
+        // stop flying
+        random = rnd(maxrand);
+//std::cout << "stop flying: " << random << std::endl;
+        if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
+        {
+            this->bHasTargetPosition_ = false;
+        }
+
+        // fly somewhere else
+        random = rnd(maxrand);
+//std::cout << "fly somewhere else: " << random << std::endl;
+        if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
+        {
+            this->searchNewTargetPosition();
+        }
+
+        // shoot
+        random = rnd(maxrand);
+//std::cout << "shoot: " << random << std::endl;
+        if (random < 75 && (this->target_ && !this->bShooting_))
+        {
+            this->bShooting_ = true;
+        }
+
+        // stop shooting
+        random = rnd(maxrand);
+//std::cout << "stop shooting: " << random << std::endl;
+        if (random < 25 && (this->bShooting_))
+        {
+            this->bShooting_ = false;
+        }
+    }
+
+    void SpaceShipAI::tick(float dt)
+    {
+        if (this->target_)
+            this->aimAtTarget();
+
+        if (this->bHasTargetPosition_)
+            this->moveToTargetPosition(dt);
+
+        if (this->bShooting_ && this->isCloseAtTarget(2000) && this->isLookingAtTarget(Ogre::Math::PI / 10.0f))
+            this->doFire();
+
+        SpaceShip::tick(dt);
+    }
+
+    void SpaceShipAI::moveToTargetPosition(float dt)
+    {
+        static Radian RadianZERO(0);
+
+//        float dotprod = (this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(this->targetPosition_ - this->getPosition());
+        Quaternion rotation = (this->getOrientation() * Ogre::Vector3::UNIT_X).getRotationTo(this->targetPosition_ - this->getPosition());
+/*
+std::cout << "scalprod: " << dotprod << std::endl;
+std::cout << "dist: " << this->targetPosition_ - this->getPosition() << std::endl;
+std::cout << "yaw: " << rotation.getYaw().valueRadians() << std::endl;
+std::cout << "pitch: " << rotation.getPitch().valueRadians() << std::endl;
+std::cout << "roll: " << rotation.getRoll().valueRadians() << std::endl;
+*/
+        this->setMoveYaw(-rotation.getRoll().valueRadians());
+        this->setMovePitch(rotation.getYaw().valueRadians());
+
+        if ((this->targetPosition_ - this->getPosition()).length() > 100)
+        {
+            this->setMoveLongitudinal(1);
+        }
+
+    }
+
+    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 (Iterator<SpaceShip> 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)))
+                {
+                    this->target_ = (*it);
+                    this->targetPosition_ = it->getPosition();
+                }
+            }
+        }
+   }
+
+    void SpaceShipAI::forgetTarget()
+    {
+        this->target_ = 0;
+        this->bShooting_ = false;
+    }
+
+    void SpaceShipAI::aimAtTarget()
+    {
+        if (!this->target_)
+            return;
+/*
+        Vector3 enemymovement = this->target_->getVelocity();
+        Vector3 distance_normalised = this->target_->getPosition() - this->getPosition();
+        distance_normalised.normalise();
+
+        float scalarprod = enemymovement.dotProduct(distance_normalised);
+        float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength();
+        if (aimoffset < 0)
+        {
+            this->bHasTargetPosition_ = false;
+            return;
+        }
+        aimoffset = -scalarprod + sqrt(aimoffset);
+        this->targetPosition_ = enemymovement + distance_normalised * aimoffset;
+        this->bHasTargetPosition_ = true;
+
+        std::cout << "targetpos: " << this->targetPosition_ << std::endl;
+*/
+        this->targetPosition_ = this->target_->getPosition();
+        this->bHasTargetPosition_ = true;
+    }
+
+    bool SpaceShipAI::isCloseAtTarget(float distance)
+    {
+        return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance);
+    }
+
+    bool SpaceShipAI::isLookingAtTarget(float angle)
+    {
+        return (this->getOrientation() * Ogre::Vector3::UNIT_X).directionEquals(this->targetPosition_ - this->getPosition(), Radian(angle));
+    }
+}
Index: /code/branches/network/src/orxonox/objects/SpaceShipAI.h
===================================================================
--- /code/branches/network/src/orxonox/objects/SpaceShipAI.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/SpaceShipAI.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _SpaceShipAI_H__
+#define _SpaceShipAI_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "SpaceShip.h"
+#include "tools/Timer.h"
+#include "util/Math.h"
+
+#define NUM_AI_TEAMS 3
+
+namespace orxonox
+{
+    class SpaceShipAI : public SpaceShip
+    {
+        public:
+            SpaceShipAI();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            static void createEnemy(int num);
+            static void killEnemies(int num);
+
+        private:
+            virtual void tick(float dt);
+            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 alive_;
+            bool bHasTargetPosition_;
+            Vector3 targetPosition_;
+            SpaceShip* target_;
+            bool bShooting_;
+
+            ColourValue teamColours_[NUM_AI_TEAMS + 1];
+    };
+}
+
+#endif /* _SpaceShipAI_H__ */
Index: /code/branches/network/src/orxonox/objects/Tickable.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/Tickable.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Tickable.cc	(revision 1545)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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);
+    }
+
+    /**
+        @brief Constructor: Registers the object in the TickableReal-list
+    */
+    TickableReal::TickableReal()
+    {
+        RegisterRootObject(TickableReal);
+    }
+}
Index: /code/branches/network/src/orxonox/objects/Tickable.h
===================================================================
--- /code/branches/network/src/orxonox/objects/Tickable.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/Tickable.h	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Tickable.h
+    @brief Definition 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"
+
+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();
+    };
+
+    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+    class _OrxonoxExport TickableReal : 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:
+            TickableReal();
+    };
+
+}
+
+#endif /* _Tickable_H__ */
Index: /code/branches/network/src/orxonox/objects/WorldEntity.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/WorldEntity.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/WorldEntity.cc	(revision 1545)
@@ -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 "OrxonoxStableHeaders.h"
+#include "WorldEntity.h"
+
+#include <string>
+#include <sstream>
+
+#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() :
+      velocity_    (0, 0, 0),
+      acceleration_(0, 0, 0),
+      rotationAxis_(0, 1, 0),
+      rotationRate_(0),
+      momentum_    (0),
+      node_        (0),
+      bStatic_     (true)
+    {
+        RegisterObject(WorldEntity);
+
+        if (GraphicsEngine::getSingleton().getSceneManager())
+        {
+          std::ostringstream name;
+          name << (WorldEntity::worldEntityCounter_s++);
+          this->setName("WorldEntity" + name.str());
+          this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
+
+          registerAllVariables();
+        }
+    }
+    
+
+    WorldEntity::~WorldEntity()
+    {
+      // just to make sure we clean out all scene nodes
+      if(this->getNode())
+        this->getNode()->removeAndDestroyAllChildren();
+    }
+
+    void WorldEntity::tick(float dt)
+    {
+        if (!this->bStatic_)
+        {
+//             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::loadParams(TiXmlElement* xmlElem)
+    {
+
+        BaseObject::loadParams(xmlElem);
+        create();
+    }
+    
+
+    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)
+    {
+        BaseObject::XMLPort(xmlelement, mode);
+
+        XMLPortParam(WorldEntity, "position", setPositionLoader2, getPosition, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionLoader, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, mode);
+        XMLPortParam(WorldEntity, "scale", setTotalScale, getScale, xmlelement, mode);
+        XMLPortParam(WorldEntity, "rotationAxis", setRotationAxisLoader, getRotationAxis, xmlelement, mode);
+        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, mode);
+
+        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
+        
+        WorldEntity::create();
+    }
+
+
+    void WorldEntity::registerAllVariables()
+    {
+      // 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->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().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);
+    }
+
+    const WorldEntity* WorldEntity::getAttachedWorldEntity(unsigned int index) const
+    {
+        if (index < this->attachedWorldEntities_.size())
+            return this->attachedWorldEntities_[index];
+        else
+            return 0;
+    }
+}
Index: /code/branches/network/src/orxonox/objects/WorldEntity.h
===================================================================
--- /code/branches/network/src/orxonox/objects/WorldEntity.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/WorldEntity.h	(revision 1545)
@@ -0,0 +1,201 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 <OgreSceneManager.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 loadParams(TiXmlElement* xmlElem);
+            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()
+                { return this->node_; }
+
+            inline void setNode(Ogre::SceneNode* node)
+                { this->node_ = node; }
+
+            inline void setPosition(const Vector3& pos)
+                { this->node_->setPosition(pos); }
+            inline void setPositionLoader1(const Vector3& pos)
+                { this->node_->setPosition(pos); }
+            inline void setPositionLoader2(Real x, Real y, Real z)
+                { this->node_->setPosition(x, y, z); }
+            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 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 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 setDirectionLoader(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 setScale(const Vector3 &scale)
+              { this->node_->setScale(scale); }
+            inline void setScale(Real x, Real y, Real z)
+              { this->node_->setScale(x, y, z); }
+            inline void setScale(Real scale)
+              { this->node_->setScale(scale, scale, scale); }
+            inline void setTotalScale(Real scale)
+              { this->node_->setScale(scale, scale, scale); }
+            inline const Vector3& getScale(void) const
+              { return this->node_->getScale(); }
+            inline void scale(const Vector3 &scale)
+              { this->node_->scale(scale); }
+            inline void scale(Real x, Real y, Real z)
+              { this->node_->scale(x, y, z); }
+            inline void scale(Real scale)
+              { this->node_->scale(scale, scale, scale); }
+
+            inline void attachObject(Ogre::MovableObject *obj)
+              { this->node_->attachObject(obj); }
+            inline void attachObject(Mesh &mesh)
+              { this->node_->attachObject(mesh.getEntity()); }
+            inline void detachObject(Ogre::MovableObject *obj)
+              { this->node_->detachObject(obj); }
+            inline void detachAllObjects()
+              { 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 setRotationAxisLoader(const Vector3& axis)
+                { this->rotationAxis_ = axis; rotationAxis_.normalise(); }
+            inline void setRotationAxis(const Vector3& axis)
+                { this->rotationAxis_ = axis; 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()
+                { 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/network/src/orxonox/objects/weapon/AmmunitionDump.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.cc	(revision 1545)
@@ -0,0 +1,127 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "AmmunitionDump.h"
+
+#include "orxonox/Orxonox.h"
+#include "BulletManager.h"
+#include "tinyxml/tinyxml.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(AmmunitionDump);
+
+  AmmunitionDump::AmmunitionDump()
+    : numberOfAmmos_(Orxonox::getSingleton()->getBulletMgr()->getNumberOfAmmos()),
+      stock_(new int[numberOfAmmos_]),
+      capacity_(new int[numberOfAmmos_])
+  {
+    RegisterObject(AmmunitionDump);
+    registerAllVariables();
+
+    for (int i = 0; i < numberOfAmmos_; i++)
+    {
+      stock_[i] = 0;
+      capacity_[i] = 0;
+    }
+  }
+
+
+  AmmunitionDump::~AmmunitionDump()
+  {
+    if (stock_)
+      delete stock_;
+    if (capacity_)
+      delete capacity_;
+  }
+
+  void AmmunitionDump::setDumpSize(const std::string &name, int size)
+  {
+    if (size < 0)
+      return;
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return;
+    capacity_[id] = size;
+  }
+
+
+  int AmmunitionDump::store(const std::string &name, int quantity)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return quantity;
+    stock_[id] += quantity;
+    if (stock_[id] > capacity_[id])
+    {
+      quantity = capacity_[id] - stock_[id];
+      stock_[id] = capacity_[id];
+      return quantity;
+    }
+    else
+      return 0;
+  }
+
+
+  int AmmunitionDump::getAmmunition(const std::string &name, int quantity)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    if (id == -1)
+      return 0;
+    if (stock_[id] >= quantity)
+      stock_[id] -= quantity;
+    else
+    {
+      quantity = stock_[id];
+      stock_[id] = 0;
+    }
+    return quantity;
+  }
+
+
+  int AmmunitionDump::getStockSize(const std::string &name)
+  {
+    int id = Orxonox::getSingleton()->getBulletMgr()->getAmmunitionID(name);
+    // FIXME changed = to ==, check if correct
+    if (id == -1)
+      return -1;
+    return stock_[id];
+  }
+
+  void AmmunitionDump::registerAllVariables(){
+    registerVar( &numberOfAmmos_, sizeof(int), network::DATA);
+
+    for (int i = 0; i < numberOfAmmos_; i++)
+    {
+      registerVar(&stock_[i], sizeof(int), network::DATA);
+      registerVar(&capacity_[i], sizeof(int), network::DATA);
+    }
+  }
+}
Index: /code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 1545)
@@ -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 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _AmmunitionDump_H__
+#define _AmmunitionDump_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport AmmunitionDump : public BaseObject, public network::Synchronisable
+  {
+  public:
+    AmmunitionDump();
+	  ~AmmunitionDump();
+
+    void setDumpSize(const std::string &name, int size);
+
+    int store(const std::string &name, int quantiy);
+
+    int getAmmunition(const std::string &name, int quantity);
+
+    int getStockSize(const std::string &name);
+
+    virtual void loadParams(TiXmlElement* xmlElem) { BaseObject::loadParams(xmlElem); };
+
+
+  protected:
+    inline bool create() { return Synchronisable::create(); }
+    void registerAllVariables();
+
+    int numberOfAmmos_;
+    int *stock_;
+    int *capacity_;
+  };
+}
+
+#endif /* _AmmunitionDump_H__ */
Index: /code/branches/network/src/orxonox/objects/weapon/BarrelGun.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BarrelGun.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BarrelGun.cc	(revision 1545)
@@ -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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BarrelGun.h"
+
+#include <OgreStringConverter.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreSceneManager.h>
+
+#include "util/Math.h"
+#include "Bullet.h"
+#include "BulletManager.h"
+#include "AmmunitionDump.h"
+#include "BaseWeapon.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(BarrelGun);
+
+  BarrelGun::BarrelGun()
+  {
+    RegisterObject(BarrelGun);
+
+    primaryFirePower_ = 100;
+    secondaryFirePower_ = 500;
+    primaryFiringRate_ = 1.0/7.0;
+    secondaryFiringRate_ = 1.0/2.0;
+    primaryBulletSpeed_ = 800;
+    secondaryBulletSpeed_ = 500;
+    magazineSize_ = 25;
+  }
+
+
+  BarrelGun::~BarrelGun()
+  {
+  }
+
+
+  void BarrelGun::primaryFire()
+  {
+    if (leftAmmo_ < 1)
+    {
+      currentState_ = IDLE;
+      return;
+    }
+
+    Ogre::SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(
+          getNode()->getWorldPosition(),
+          getNode()->getWorldOrientation());
+
+    Ogre::Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"
+      + Ogre::StringConverter::toString(bulletCounter_++), "Barrel.mesh");
+
+    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
+          .normalisedCopy() * primaryBulletSpeed_;
+    speed += getVelocity();
+
+	  temp->setScale(Vector3(1, 1, 1) * 1.5);
+    temp->roll(Degree(90));
+
+    Bullet* bullet = new Bullet();
+    bullet->setNode(temp);
+    bullet->attachObject(bulletEntity);
+    bullet->setVelocity(speed);
+	  bulletManager_->addBullet(bullet);
+
+    --leftAmmo_;
+  }
+
+
+  void BarrelGun::primaryFiring(float time)
+  {
+    if (time > primaryFiringRate_)
+    {
+      currentState_ = IDLE;
+    }
+  }
+
+
+  void BarrelGun::secondaryFire()
+  {
+    if (leftAmmo_ < 5)
+    {
+      currentState_ = IDLE;
+      return;
+    }
+
+    Ogre::SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(
+          getNode()->getWorldPosition(),
+          getNode()->getWorldOrientation());
+
+    Ogre::Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"
+      + Ogre::StringConverter::toString(bulletCounter_++), "Barrel.mesh");
+
+    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
+          .normalisedCopy() * secondaryBulletSpeed_*0.5;
+    speed += getVelocity();
+
+	  temp->setScale(Vector3(1, 1, 1) * 3);
+	  temp->roll(Degree(90));
+
+    Bullet* bullet = new Bullet();
+    bullet->setNode(temp);
+    bullet->attachObject(bulletEntity);
+    bullet->setVelocity(speed);
+	  bulletManager_->addBullet(bullet);
+
+
+    leftAmmo_ -= 5;
+  }
+
+
+  void BarrelGun::secondaryFiring(float time)
+  {
+    if (time > secondaryFiringRate_)
+      currentState_ = IDLE;
+  }
+
+}
Index: /code/branches/network/src/orxonox/objects/weapon/BarrelGun.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BarrelGun.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BarrelGun.h	(revision 1545)
@@ -0,0 +1,65 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _BarrelGun_H__
+#define _BarrelGun_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "BaseWeapon.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport BarrelGun : public BaseWeapon
+  {
+ public:
+    BarrelGun();
+	  virtual ~BarrelGun();
+
+    //virtual void tick(float dt);
+
+  protected:
+    void primaryFire();
+
+    void primaryFiring(float);
+
+    void secondaryFire();
+
+    void secondaryFiring(float);
+
+  public:
+
+  protected:
+
+  };
+}
+
+#endif /* _BarrelGun_H__ */
Index: /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.cc	(revision 1545)
@@ -0,0 +1,186 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "BaseWeapon.h"
+
+#include <OgreStringConverter.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreSceneManager.h>
+
+#include "util/Math.h"
+#include "Orxonox.h"
+#include "Bullet.h"
+#include "BulletManager.h"
+#include "AmmunitionDump.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  float BaseWeapon::nextActionValidityPeriod_s = 0.5;
+
+  BaseWeapon::BaseWeapon()
+    : sceneMgr_(GraphicsEngine::getSingleton().getSceneManager()),
+      bulletCounter_(0),
+      bulletManager_(Orxonox::getSingleton()->getBulletMgr()),
+      ammoDump_(NULL),
+      primaryFireRequest_(false), secondaryFireRequest_(false),
+      totalTime_(0.0f), actionStartTime_(0.0f),
+      currentState_(IDLE), secondaryFired_(false),
+      nextAction_(NOTHING), actionAdded_(false),
+      timeSinceNextActionAdded_(0.0f),
+      leftAmmo_(0)
+  {
+    RegisterObject(BaseWeapon);
+  }
+
+
+  BaseWeapon::~BaseWeapon()
+  {
+  }
+
+
+  bool BaseWeapon::addAction(const Action act)
+  {
+    if (nextAction_ == NOTHING)
+    {
+      nextAction_ = act;
+      actionAdded_ = true;
+      return true;
+    }
+    else
+      return false;
+  }
+
+
+  void BaseWeapon::primaryFireRequest()
+  {
+    primaryFireRequest_ = true;
+  }
+
+
+  void BaseWeapon::secondaryFireRequest()
+  {
+    secondaryFireRequest_ = true;
+  }
+
+
+  void BaseWeapon::tick(float dt)
+  {
+    totalTime_ += dt;
+    // process action adder
+    if (actionAdded_)
+    {
+      timeSinceNextActionAdded_ = totalTime_;
+      actionAdded_ = false;
+    }
+
+    switch (currentState_)
+    {
+    case IDLE:
+      break;
+
+    case PRIMARY_FIRE:
+      primaryFiring(totalTime_ - actionStartTime_);
+      break;
+
+    case SECONDARY_FIRE:
+      secondaryFiring(totalTime_ - actionStartTime_);
+      break;
+
+    case RELOADING:
+      break;
+
+    case CHANGING_AMMO:
+      break;
+    }
+
+    if (currentState_ == IDLE)
+    {
+      // first, process next action
+      if (nextAction_ != NOTHING)
+      {
+        actionStartTime_ = totalTime_;
+        switch (nextAction_)
+        {
+        case RELOAD:
+          leftAmmo_ += ammoDump_->getAmmunition("Barrel", magazineSize_ - leftAmmo_);
+          break;
+
+        case CHANGE_AMMO:
+          break;
+
+        case SPECIAL:
+          break;
+
+        default:
+          break;
+        }
+
+        // pay attention when multithreaded!
+        nextAction_ = NOTHING;
+      }
+      else
+      {
+        // secondly, execute firing
+        if (primaryFireRequest_ && !(secondaryFired_ && secondaryFireRequest_))
+        {
+          actionStartTime_ = totalTime_;
+          currentState_ = PRIMARY_FIRE;
+          secondaryFired_ = false;
+          primaryFire();
+        }
+        else if (secondaryFireRequest_)
+        {
+          actionStartTime_ = totalTime_;
+          currentState_ = SECONDARY_FIRE;
+          secondaryFired_ = true;
+          secondaryFire();
+        }
+      }
+    }
+
+    primaryFireRequest_ = false;
+    secondaryFireRequest_ = false;
+
+    if (totalTime_ - timeSinceNextActionAdded_ > nextActionValidityPeriod_s)
+      nextAction_ = NOTHING;
+  }
+
+
+  int BaseWeapon::getAmmoState()
+  {
+    return leftAmmo_;
+  }
+
+  void BaseWeapon::setAmmoDump(AmmunitionDump* dump)
+  {
+    this->ammoDump_ = dump;
+  }
+}
Index: /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BaseWeapon.h	(revision 1545)
@@ -0,0 +1,127 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 _BaseWeapon_H__
+#define _BaseWeapon_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "../Model.h"
+
+
+namespace orxonox {
+  class _OrxonoxExport BaseWeapon : public Model
+  {
+  public:
+    enum Action {
+      NOTHING  = 0,
+      RELOAD   = 1,
+      CHANGE_AMMO  = 2,
+      SPECIAL  = 3
+    };
+
+  protected:
+    enum State {
+      IDLE = 0,
+      PRIMARY_FIRE = 1,
+      SECONDARY_FIRE = 2,
+      RELOADING = 3,
+      CHANGING_AMMO = 4,
+    };
+
+  public:
+    BaseWeapon();
+	  virtual ~BaseWeapon();
+
+    bool addAction(const Action);
+
+    void primaryFireRequest();
+
+    void secondaryFireRequest();
+
+    int getAmmoState();
+
+    void setAmmoDump(AmmunitionDump*);
+
+    inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); };
+
+    virtual void tick(float dt);
+
+  protected:
+    virtual void primaryFire() = 0;
+
+    virtual void primaryFiring(float) = 0;
+
+    virtual void secondaryFire() = 0;
+
+    virtual void secondaryFiring(float) = 0;
+
+    virtual void registerAllVariables() { };
+
+  public:
+
+  protected:
+    Ogre::SceneManager *sceneMgr_;
+
+    int bulletCounter_;
+    BulletManager *bulletManager_;
+
+    AmmunitionDump *ammoDump_;
+
+    bool primaryFireRequest_;
+    bool secondaryFireRequest_;
+
+    float totalTime_;
+    float actionStartTime_;
+
+    State currentState_;
+    bool secondaryFired_;
+
+    Action nextAction_;
+    bool actionAdded_;
+    float timeSinceNextActionAdded_;
+    static float nextActionValidityPeriod_s;
+
+    // weapon properties
+    int leftAmmo_;
+    float primaryFirePower_;
+    float secondaryFirePower_;
+    float primaryFiringRate_;
+    float secondaryFiringRate_;
+    Real primaryBulletSpeed_;
+    Real secondaryBulletSpeed_;
+
+    int magazineSize_;
+
+  };
+}
+
+#endif /* _BaseWeapon_H__ */
Index: /code/branches/network/src/orxonox/objects/weapon/Bullet.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/Bullet.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/Bullet.cc	(revision 1545)
@@ -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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Bullet.h"
+
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(Bullet);
+
+  Bullet::Bullet()
+  {
+    RegisterObject(Bullet);
+  }
+
+  Bullet::~Bullet()
+  {
+  }
+}
Index: /code/branches/network/src/orxonox/objects/weapon/Bullet.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/Bullet.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/Bullet.h	(revision 1545)
@@ -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 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _Bullet_H__
+#define _Bullet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+#include "../Model.h"
+
+namespace orxonox {
+  class _OrxonoxExport Bullet : public Model
+  {
+  public:
+	  Bullet();
+	  ~Bullet();
+
+    virtual void tick(float dt) { }
+
+    inline virtual void loadParams(TiXmlElement* xmlElem) { Model::loadParams(xmlElem); };
+ };
+}
+
+#endif /* _Bullet_H__ */
Index: /code/branches/network/src/orxonox/objects/weapon/BulletManager.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BulletManager.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BulletManager.cc	(revision 1545)
@@ -0,0 +1,114 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "BulletManager.h"
+
+#include "Bullet.h"
+#include "core/CoreIncludes.h"
+
+
+namespace orxonox {
+  CreateFactory(BulletManager);
+
+  BulletManager::BulletManager() : bulletsSize_(8), bulletsIndex_(0)
+  {
+    RegisterObject(BulletManager);
+    registerAllVariables();
+    bullets_ = new Bullet*[bulletsSize_];
+  }
+
+
+  BulletManager::~BulletManager()
+  {
+    // clean up the bullet list
+    if (bullets_)
+    {
+      for (int i = 0; i < bulletsIndex_; i++)
+        delete bullets_[i];
+      delete bullets_;
+    }
+  }
+
+
+  void BulletManager::addBullet(Bullet *bullet)
+  {
+    // resize array if neccessary (double the size then)
+    if (bulletsIndex_ >= bulletsSize_)
+    {
+      // redimension the array
+      Bullet **tempArray = new Bullet*[2*bulletsSize_];
+      for (int i = 0; i < bulletsSize_; i++)
+        tempArray[i] = bullets_[i];
+      bulletsSize_ *= 2;
+      delete bullets_;
+      bullets_ = tempArray;
+    }
+
+    // add the bullet to the list
+    bullets_[bulletsIndex_++] = bullet;
+  }
+
+
+  void BulletManager::tick(float dt)
+  {
+    // update the bullet positions
+    for (int i = 0; i < bulletsIndex_; i++)
+    {
+      bullets_[i]->getNode()->translate(bullets_[i]->getVelocity()*dt);
+      //bullets_[i]->getNode()->yaw(Degree(dt*100));
+      //bullets_[i]->getNode()->roll(Degree(dt*300));
+    }
+  }
+
+  int BulletManager::getAmmunitionID(const std::string &ammoName)
+  {
+    std::string ammoTypes[] = { "Energy Cell", "Barrel", "Lead Shot" };
+    int ammoTypesLength = 3;
+
+    for (int i = 0; i < ammoTypesLength; i++)
+    {
+      if (ammoTypes[i] == ammoName)
+        return i;
+    }
+    return -1;
+  }
+
+  int BulletManager::getNumberOfAmmos()
+  {
+    return 3;
+  }
+
+  void BulletManager::registerAllVariables(){
+    registerVar(&bulletsSize_, sizeof(int), network::DATA);
+    registerVar(&bulletsIndex_, sizeof(int), network::DATA);
+    // TODO we got a problem here:
+    // there is no possibility (so far) to synchronise pointers to objects
+  }
+
+}
Index: /code/branches/network/src/orxonox/objects/weapon/BulletManager.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/BulletManager.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/BulletManager.h	(revision 1545)
@@ -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 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _BulletManager_H__
+#define _BulletManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+
+#include "network/Synchronisable.h"
+#include "tinyxml/tinyxml.h"
+#include "core/BaseObject.h"
+#include "core/Tickable.h"
+
+namespace orxonox {
+  class _OrxonoxExport BulletManager : public BaseObject, public network::Synchronisable, public Tickable
+  {
+  public:
+    BulletManager();
+	  virtual ~BulletManager();
+
+    void addBullet(Bullet*);
+
+    int getAmmunitionID(const std::string&);
+
+    int getNumberOfAmmos();
+
+    virtual void tick(float dt);
+
+    inline virtual void loadParams(TiXmlElement* xmlElem) { BaseObject::loadParams(xmlElem); };
+
+  protected:
+    inline bool create() { return Synchronisable::create(); }
+    void registerAllVariables();
+
+    // Bullet array
+	  Bullet **bullets_;
+	  int bulletsSize_;
+	  int bulletsIndex_;
+  };
+}
+
+#endif /* _BulletManager_H__ */
Index: /code/branches/network/src/orxonox/objects/weapon/WeaponStation.cc
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/WeaponStation.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/WeaponStation.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WeaponStation.h"
+
+#include "BaseWeapon.h"
+
+
+namespace orxonox {
+  WeaponStation::WeaponStation(int stationSize)
+        : slots_(new BaseWeapon*[stationSize]),
+          lastActiveSlotIndex_(-1), stationSize_(stationSize)
+  {
+  	//slots_ = new BaseWeapon*[stationSize];
+  }
+
+
+  WeaponStation::~WeaponStation()
+  {
+    if (slots_)
+      delete slots_;
+    // when factory available: delete weapons too
+  }
+
+
+  bool WeaponStation::addWeapon(BaseWeapon *weapon)
+  {
+    if (lastActiveSlotIndex_ == stationSize_ - 1)
+      return false;
+
+    // this is ugly, but for the time being, it has to fit.
+    slots_[++lastActiveSlotIndex_] = weapon;
+    selectedSlot_ = slots_ + lastActiveSlotIndex_;
+    return true;
+  }
+
+
+  BaseWeapon* WeaponStation::selectWeapon(int slotNumber)
+  {
+    if (slotNumber < lastActiveSlotIndex_)
+      return NULL;
+    return slots_[slotNumber];
+  }
+
+}
Index: /code/branches/network/src/orxonox/objects/weapon/WeaponStation.h
===================================================================
--- /code/branches/network/src/orxonox/objects/weapon/WeaponStation.h	(revision 1545)
+++ /code/branches/network/src/orxonox/objects/weapon/WeaponStation.h	(revision 1545)
@@ -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 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _WeaponStation_H__
+#define _WeaponStation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+
+
+namespace orxonox {
+  class _OrxonoxExport WeaponStation
+  {
+  public:
+    WeaponStation(int slotSize);
+	  ~WeaponStation();
+
+    bool addWeapon(BaseWeapon*);
+
+    //bool removeCurrentWeapon();
+
+    // TODO: access every weapon by name
+    BaseWeapon* selectWeapon(int slotNumber);
+
+  protected:
+
+  public:
+
+  protected:
+    // slot management
+    BaseWeapon **slots_;
+    BaseWeapon **selectedSlot_;
+    int lastActiveSlotIndex_;
+    int stationSize_;
+
+  };
+}
+
+#endif /* _WeaponStation_H__ */
Index: /code/branches/network/src/orxonox/particle/ParticleInterface.cc
===================================================================
--- /code/branches/network/src/orxonox/particle/ParticleInterface.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/particle/ParticleInterface.cc	(revision 1545)
@@ -0,0 +1,148 @@
+/*
+*   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 <Ogre.h>
+// #include <OIS/OIS.h>
+// #include <CEGUI/CEGUI.h>
+// #include <CEGUIRenderer.h>
+
+
+
+namespace orxonox {
+  using namespace Ogre;
+
+  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
+  {
+    sceneManager_ = sceneManager;
+    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
+
+    //Variabeln einlesen, Emitter1_ ist Referenz-Emitter
+    velocity_ = particleSystem_->getSpeedFactor();
+    colour_ = particleSystem_->getEmitter(0)->getColour();
+    rate_ = particleSystem_->getEmitter(0)->getEmissionRate();
+    distance_ = particleSystem_->getEmitter(0)->getTimeToLive();
+
+    //Anzahl der Emitter
+    numberOfEmitters_ = particleSystem_->getNumEmitters();
+    standardizeEmitters();
+  }
+
+  ParticleInterface::~ParticleInterface(void)
+  {
+    while(particleSystem_->getNumEmitters()>0)
+      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
+    sceneManager_->destroyParticleSystem(particleSystem_);
+  }
+
+  void ParticleInterface::standardizeEmitters(void)
+  {
+    //Abgleichen der anderen Emitter an die Variabeln
+    for (int i=0; i < numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setColour( colour_ );
+      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
+      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
+    }
+
+  }
+
+  void ParticleInterface::setVelocity(Real v)
+  {
+    velocity_ = v;
+    //partikel anpassen
+    particleSystem_->setSpeedFactor(v);
+  }
+
+  void ParticleInterface::setRate(float r)
+  {
+    rate_ = r;
+    //partikel anpassen
+    for (int i=0; i<numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
+    }
+  }
+
+  void ParticleInterface::setDistance(Real d)
+  {
+    distance_ = d;
+    //partikel anpassen
+    for (int i=0; i < numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
+    }
+  }
+
+  void ParticleInterface::setColour(ColourValue colour)
+  {
+    colour_ = colour;
+    //partikel anpassen
+    for (int i=0; i < numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setColour(colour_);
+    }
+  }
+
+  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
+  {
+    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
+    return particleSystem_->getEmitter(emitterNr);
+  }
+
+  void ParticleInterface::newEmitter ()
+  {
+    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
+    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
+    numberOfEmitters_++;
+  }
+
+  // TODO check if this really works
+  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
+  {
+    return particleSystem_->getEmitter(emitterNr)->getPosition();
+  }
+
+  void ParticleInterface::setDirection ( Vector3 direction )
+  {
+    for(int i=0; i < numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setDirection(direction);
+    }
+  }
+
+  void ParticleInterface::switchEnable(){
+    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
+    for(int i=0; i < numberOfEmitters_; i++) {
+      particleSystem_->getEmitter(i)->setEnabled(enable);
+    }
+  }
+
+}
Index: /code/branches/network/src/orxonox/particle/ParticleInterface.h
===================================================================
--- /code/branches/network/src/orxonox/particle/ParticleInterface.h	(revision 1545)
+++ /code/branches/network/src/orxonox/particle/ParticleInterface.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleInterface_H__
+#define _ParticleInterface_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+// #include "ParticleInterface.h"
+// #include <Ogre.h>
+// #include <OIS/OIS.h>
+// #include <CEGUI/CEGUI.h>
+// #include <CEGUIRenderer.h>
+#include <OgreParticleSystem.h>
+#include <OgreParticleEmitter.h>
+#include <OgreSceneManager.h>
+
+#include "util/Math.h"
+
+
+namespace orxonox
+{
+
+  class _OrxonoxExport ParticleInterface
+  {
+  public:
+
+    ParticleInterface( Ogre::SceneManager *sceneManager, std::string name, std::string templateName );
+    ~ParticleInterface( void );
+
+    inline void addToSceneNode( Ogre::SceneNode* sceneNode )
+        { sceneNode_ = sceneNode; sceneNode_->attachObject(particleSystem_);};
+    inline void detachFromSceneNode( void )
+        { sceneNode_->detachObject(particleSystem_); sceneNode_ = NULL;};
+
+    Ogre::ParticleEmitter* getEmitter ( int emitterNr );
+    void newEmitter ( void );
+
+    Vector3 getPositionOfEmitter ( int emitterNr );
+    inline void setPositionOfEmitter ( int emitterNr, Vector3 position )
+        { particleSystem_->getEmitter(emitterNr)->setPosition(position); };
+
+    inline Vector3 getDirection ( void )
+        { return particleSystem_->getEmitter(0)->getDirection(); };
+    void setDirection ( Vector3 direction );
+
+    inline Real getVelocity()
+        {return velocity_; };
+    void setVelocity( Real v );
+
+    inline float getRate()
+      { return rate_; };
+    void setRate( float r );
+
+    inline Real getDistance()
+        { return distance_; };
+    void setDistance( Real d );
+
+    inline ColourValue getColour( void )
+        {return colour_;};
+    void setColour( ColourValue colour );
+
+    void switchEnable();
+
+    inline Ogre::ParticleSystem* getParticleSystem()
+        { return this->particleSystem_; };
+
+  private:
+    Ogre::SceneNode *sceneNode_;
+    Ogre::SceneManager *sceneManager_;
+    Ogre::ParticleSystem *particleSystem_;
+    Real distance_;
+    Real velocity_;
+    float rate_;
+    ColourValue colour_;
+    int numberOfEmitters_;
+
+    void standardizeEmitters();
+  };
+
+}
+
+#endif /* _ParticleInterface_H__ */
Index: /code/branches/network/src/orxonox/tools/BillboardSet.cc
===================================================================
--- /code/branches/network/src/orxonox/tools/BillboardSet.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/BillboardSet.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ */
+
+#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, const ColourValue& colour, int count, const Vector3& position)
+    {
+        std::ostringstream name;
+        name << (BillboardSet::billboardSetCounter_s++);
+        this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_->createBillboard(position, colour);
+        this->billboardSet_->setMaterialName(file);
+    }
+
+    BillboardSet::~BillboardSet()
+    {
+        if (this->billboardSet_)
+            GraphicsEngine::getSingleton().getSceneManager()->destroyBillboardSet(this->billboardSet_);
+    }
+}
Index: /code/branches/network/src/orxonox/tools/BillboardSet.h
===================================================================
--- /code/branches/network/src/orxonox/tools/BillboardSet.h	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/BillboardSet.h	(revision 1545)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _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, const ColourValue& colour = ColourValue(1.0, 1.0, 1.0), int count = 1, const Vector3& position = Vector3::ZERO);
+
+            inline Ogre::BillboardSet* getBillboardSet()
+                { return this->billboardSet_; }
+
+            inline const std::string& getName() const
+                { return this->billboardSet_->getName(); }
+
+        private:
+            static unsigned int billboardSetCounter_s;
+            Ogre::BillboardSet* billboardSet_;
+    };
+}
+
+#endif /* _BillboardSet_H__ */
Index: /code/branches/network/src/orxonox/tools/Light.cc
===================================================================
--- /code/branches/network/src/orxonox/tools/Light.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Light.cc	(revision 1545)
@@ -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::getSingleton().getSceneManager()->createLight("Light" + name.str());
+        this->light_->setType(type);
+        this->light_->setDiffuseColour(diffuse);
+        this->light_->setSpecularColour(specular);
+    }
+
+    Light::~Light()
+    {
+        if (this->light_)
+            GraphicsEngine::getSingleton().getSceneManager()->destroyLight(this->light_);
+    }
+}
Index: /code/branches/network/src/orxonox/tools/Light.h
===================================================================
--- /code/branches/network/src/orxonox/tools/Light.h	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Light.h	(revision 1545)
@@ -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/network/src/orxonox/tools/Mesh.cc
===================================================================
--- /code/branches/network/src/orxonox/tools/Mesh.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Mesh.cc	(revision 1545)
@@ -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"
+
+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++);
+        this->entity_ = GraphicsEngine::getSingleton().getSceneManager()->createEntity("Mesh" + name.str(), file);
+    }
+
+    Mesh::~Mesh()
+    {
+        if (this->entity_)
+            GraphicsEngine::getSingleton().getSceneManager()->destroyEntity(this->entity_);
+    }
+}
Index: /code/branches/network/src/orxonox/tools/Mesh.h
===================================================================
--- /code/branches/network/src/orxonox/tools/Mesh.h	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Mesh.h	(revision 1545)
@@ -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:
+ *      ...
+ *   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(); }
+
+        private:
+            static unsigned int meshCounter_s;
+            Ogre::Entity* entity_;
+    };
+}
+
+#endif /* _Mesh_H__ */
Index: /code/branches/network/src/orxonox/tools/Timer.cc
===================================================================
--- /code/branches/network/src/orxonox/tools/Timer.cc	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Timer.cc	(revision 1545)
@@ -0,0 +1,146 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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"
+
+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()
+    {
+      if (this->executor_)
+          delete this->executor_;
+    }
+
+    /**
+        @brief Executes the executor.
+    */
+    void TimerBase::run() const
+    {
+        (*this->executor_)();
+    }
+
+    /**
+        @brief Updates the timer before the frames are rendered.
+    */
+    void TimerBase::tick(float dt)
+    {
+        if (this->bActive_)
+        {
+            // If active: Decrease the timer by the duration of the last frame
+            this->time_ -= dt;
+
+            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/network/src/orxonox/tools/Timer.h
===================================================================
--- /code/branches/network/src/orxonox/tools/Timer.h	(revision 1545)
+++ /code/branches/network/src/orxonox/tools/Timer.h	(revision 1545)
@@ -0,0 +1,198 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 "objects/Tickable.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 Tickable
+    {
+        public:
+            ~TimerBase();
+
+            void run() const;
+
+            /** @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 Gives the Timer some extra time. @param time The amount of extra time in seconds */
+            inline void addTime(float time)
+                { this->time_ += time; }
+            /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
+            inline void removeTime(float time)
+                { this->time_ -= time; }
+            /** @brief Sets the interval of the Timer. @param interval The interval */
+            inline void setInterval(float interval)
+                { this->interval_ = interval; }
+            /** @brief Sets bLoop to a given value. @param bLoop True = loop */
+            inline void setLoop(bool bLoop)
+                { this->bLoop_ = bLoop; }
+
+            void tick(float dt);
+
+        protected:
+            TimerBase();
+
+            Executor* executor_; //!< The executor of the function that should be called when the time expires
+
+            float interval_;     //!< The time-interval in seconds
+            bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
+            bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
+
+            float time_;         //!< Internal variable, counting the time till the next function-call
+    };
+
+    //! 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->interval_ = interval;
+                this->bLoop_ = bLoop;
+                executor->setObject(object);
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = 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->interval_ = interval;
+                this->bLoop_ = bLoop;
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = interval;
+            }
+    };
+
+}
+
+#endif /* _Timer_H__ */
Index: /code/branches/network/src/tinyxml/CMakeLists.txt
===================================================================
--- /code/branches/network/src/tinyxml/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/tinyxml/CMakeLists.txt	(revision 1545)
@@ -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/network/src/tinyxml/ticpp.cc
===================================================================
--- /code/branches/network/src/tinyxml/ticpp.cc	(revision 1545)
+++ /code/branches/network/src/tinyxml/ticpp.cc	(revision 1545)
@@ -0,0 +1,1131 @@
+#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
+
+#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() );
+	}
+}
+
+//*****************************************************************************
+
+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/network/src/tinyxml/ticpp.h
===================================================================
--- /code/branches/network/src/tinyxml/ticpp.h	(revision 1545)
+++ /code/branches/network/src/tinyxml/ticpp.h	(revision 1545)
@@ -0,0 +1,1808 @@
+#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.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>
+
+/**
+@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/network/src/tinyxml/ticpprc.h
===================================================================
--- /code/branches/network/src/tinyxml/ticpprc.h	(revision 1545)
+++ /code/branches/network/src/tinyxml/ticpprc.h	(revision 1545)
@@ -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/network/src/tinyxml/tinystr.cc
===================================================================
--- /code/branches/network/src/tinyxml/tinystr.cc	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinystr.cc	(revision 1545)
@@ -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/network/src/tinyxml/tinystr.h
===================================================================
--- /code/branches/network/src/tinyxml/tinystr.h	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinystr.h	(revision 1545)
@@ -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/network/src/tinyxml/tinyxml.cc
===================================================================
--- /code/branches/network/src/tinyxml/tinyxml.cc	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinyxml.cc	(revision 1545)
@@ -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/network/src/tinyxml/tinyxml.h
===================================================================
--- /code/branches/network/src/tinyxml/tinyxml.h	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinyxml.h	(revision 1545)
@@ -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/network/src/tinyxml/tinyxmlerror.cc
===================================================================
--- /code/branches/network/src/tinyxml/tinyxmlerror.cc	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinyxmlerror.cc	(revision 1545)
@@ -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/network/src/tinyxml/tinyxmlparser.cc
===================================================================
--- /code/branches/network/src/tinyxml/tinyxmlparser.cc	(revision 1545)
+++ /code/branches/network/src/tinyxml/tinyxmlparser.cc	(revision 1545)
@@ -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/network/src/tolua/CMakeLists.txt
===================================================================
--- /code/branches/network/src/tolua/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/tolua/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,26 @@
+SET (TOLUALIB_SRC_FILES
+  tolua_event.c
+  tolua_is.c
+  tolua_map.c
+  tolua_push.c
+  tolua_to.c
+)
+
+ADD_LIBRARY (tolualib ${TOLUALIB_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolualib
+  ${Lua_LIBRARIES}
+)
+
+SET (TOLUAEXE_SRC_FILES
+  tolua.c
+  toluabind.c
+)
+
+ADD_EXECUTABLE (tolua ${TOLUAEXE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolua
+  ${Lua_LIBRARIES}
+  tolualib
+  m
+)
Index: /code/branches/network/src/tolua/tolua++.h
===================================================================
--- /code/branches/network/src/tolua/tolua++.h	(revision 1545)
+++ /code/branches/network/src/tolua/tolua++.h	(revision 1545)
@@ -0,0 +1,157 @@
+/* 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
+
+#ifndef TOLUA_API
+#define TOLUA_API extern
+#endif
+
+#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/network/src/tolua/tolua.c
===================================================================
--- /code/branches/network/src/tolua/tolua.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua.c	(revision 1545)
@@ -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/network/src/tolua/tolua_event.c
===================================================================
--- /code/branches/network/src/tolua/tolua_event.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_event.c	(revision 1545)
@@ -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/network/src/tolua/tolua_event.h
===================================================================
--- /code/branches/network/src/tolua/tolua_event.h	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_event.h	(revision 1545)
@@ -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/network/src/tolua/tolua_is.c
===================================================================
--- /code/branches/network/src/tolua/tolua_is.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_is.c	(revision 1545)
@@ -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/network/src/tolua/tolua_map.c
===================================================================
--- /code/branches/network/src/tolua/tolua_map.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_map.c	(revision 1545)
@@ -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/network/src/tolua/tolua_push.c
===================================================================
--- /code/branches/network/src/tolua/tolua_push.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_push.c	(revision 1545)
@@ -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/network/src/tolua/tolua_to.c
===================================================================
--- /code/branches/network/src/tolua/tolua_to.c	(revision 1545)
+++ /code/branches/network/src/tolua/tolua_to.c	(revision 1545)
@@ -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/network/src/tolua/toluabind.c
===================================================================
--- /code/branches/network/src/tolua/toluabind.c	(revision 1545)
+++ /code/branches/network/src/tolua/toluabind.c	(revision 1545)
@@ -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 */
+TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+}
+
+/* Open function */
+TOLUA_API int tolua_tolua_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,0);
+ tolua_beginmodule(tolua_S,NULL);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+   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
+ TOLUA_API int luaopen_tolua (lua_State* tolua_S) {
+ return tolua_tolua_open(tolua_S);
+};
+#endif
+
Index: /code/branches/network/src/tolua/toluabind.h
===================================================================
--- /code/branches/network/src/tolua/toluabind.h	(revision 1545)
+++ /code/branches/network/src/tolua/toluabind.h	(revision 1545)
@@ -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/network/src/util/ArgReader.cc
===================================================================
--- /code/branches/network/src/util/ArgReader.cc	(revision 1545)
+++ /code/branches/network/src/util/ArgReader.cc	(revision 1545)
@@ -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:
+ *      Benjamin Knecht <beni_at_orxonox.net>
+ *
+ */
+
+/**
+ @file  ArgReader.cc
+ @brief Argument Reader
+ */
+
+#include "ArgReader.h"
+#include "SubString.h"
+
+ArgReader::ArgReader(int argc, char **argv)
+{
+  failure_ = false;
+  errorString_ = "";
+  CmdLineArg arg;
+
+  int i = 1;
+  while (i < argc)
+  {
+    if (argv[i][0] == '-' && argv[i][1] == '-') // name
+    {
+      if (argv[i][2] == '\0')
+      {
+        failure_ = true;
+        errorString_ += "Expected word after \"--\".\n";
+      }
+      arg.bChecked_ = false;
+      arg.name_ = argv[i] + 2;
+      arg.value_ = "";
+      arguments_.push_back(arg);
+    }
+    else // value
+    {
+      if (arguments_.size() == 0)
+      {
+        failure_ = true;
+        errorString_ += "Expected \"--\" in command line arguments.\n";
+        arg.bChecked_ = false;
+        arg.name_ = "";
+        arg.value_ = "";
+        arguments_.push_back(arg);
+      }
+
+      if (arguments_.back().value_ != "")
+        arguments_.back().value_ += " " + std::string(argv[i]);
+      else
+        arguments_.back().value_ = argv[i];
+    }
+    ++i;
+  }
+}
+
+bool ArgReader::errorHandling()
+{
+  bool argumentsChecked = true;
+  for (unsigned int i = 1; i < arguments_.size(); ++i)
+    argumentsChecked &= arguments_[i].bChecked_;
+
+  if (!argumentsChecked)
+    errorString_ += "Not all arguments could be matched.\n";
+
+  return !argumentsChecked || failure_;
+}
+
+const std::string& ArgReader::getErrorString()
+{
+  return errorString_;
+}
Index: /code/branches/network/src/util/ArgReader.h
===================================================================
--- /code/branches/network/src/util/ArgReader.h	(revision 1545)
+++ /code/branches/network/src/util/ArgReader.h	(revision 1545)
@@ -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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht <beni_at_orxonox.net>
+ *
+ */
+
+/**
+ @file  Argreader.h
+ @brief reads arguments
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _ArgReader_H__
+#define _ArgReader_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <vector>
+#include "Convert.h"
+
+struct _UtilExport CmdLineArg
+{
+  std::string name_;
+  std::string value_;
+  bool bChecked_;
+};
+
+class _UtilExport ArgReader
+{
+  public:
+    ArgReader(int argc, char **argv);
+    template <class T>
+    void checkArgument(std::string option, T* value, bool must = false);
+    bool errorHandling();
+    const std::string& getErrorString();
+
+  private:
+    std::vector<CmdLineArg> arguments_;
+    bool failure_;
+    std::string errorString_;
+};
+
+template <class T>
+void ArgReader::checkArgument(std::string option, T* value, bool must)
+{
+  unsigned int iArg = 0;
+  while (iArg < arguments_.size())
+  {
+    if (arguments_[iArg].name_ == option)
+      break;
+    ++iArg;
+  }
+  if (iArg == arguments_.size())
+  {
+    if (must)
+    {
+      failure_ = true;
+      errorString_ += "Cannot find mandatory argument \"" + option + "\"\n";
+      return;
+    }
+    else
+      return;
+  }
+
+  arguments_[iArg].bChecked_ = true;
+
+  if (!convertValue(value, arguments_[iArg].value_))
+  {
+    failure_ = true;
+    errorString_ += "Cannot convert argument value for option \"" + option + "\"\n";
+  }
+}
+
+template <>
+void ArgReader::checkArgument(std::string option, bool* value, bool must)
+{
+  // for type bool, only check whether the option was set or not
+  unsigned int iArg = 0;
+  while (iArg < arguments_.size())
+  {
+    if (arguments_[iArg].name_ == option)
+    {
+      arguments_[iArg].bChecked_ = true;
+      *value = true;
+      break;
+    }
+    ++iArg;
+  }
+  if (iArg == arguments_.size())
+    *value = false;
+}
+
+#endif /* _ArgReader_H__ */
Index: /code/branches/network/src/util/CMakeLists.txt
===================================================================
--- /code/branches/network/src/util/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/util/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,22 @@
+SET(UTIL_SRC_FILES
+  ArgReader.cc
+  Clipboard.cc
+  ExprParser.cc
+  Math.cc
+  MultiTypePrimitive.cc
+  MultiTypeString.cc
+  MultiTypeMath.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/network/src/util/Clipboard.cc
===================================================================
--- /code/branches/network/src/util/Clipboard.cc	(revision 1545)
+++ /code/branches/network/src/util/Clipboard.cc	(revision 1545)
@@ -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:
+ *      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
+ */
+
+#include "Clipboard.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+    #include <windows.h>
+
+    bool toClipboard(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 (...)
+        {
+        }
+        return false;
+    }
+
+    std::string fromClipboard()
+    {
+        try
+        {
+            if (OpenClipboard(0))
+            {
+                HANDLE hData = GetClipboardData(CF_TEXT);
+                std::string output = (char*)GlobalLock(hData);
+                GlobalUnlock(hData);
+                CloseClipboard();
+
+                return output;
+            }
+        }
+        catch (...)
+        {
+        }
+        return "";
+    }
+#else
+    std::string clipboard = "";
+
+    bool toClipboard(std::string text)
+    {
+        clipboard = text;
+        return true;
+    }
+
+    std::string fromClipboard()
+    {
+        return clipboard;
+    }
+#endif
Index: /code/branches/network/src/util/Clipboard.h
===================================================================
--- /code/branches/network/src/util/Clipboard.h	(revision 1545)
+++ /code/branches/network/src/util/Clipboard.h	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Clipboard_H__
+#define _Clipboard_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+
+
+_UtilExport bool toClipboard(std::string text);
+_UtilExport std::string fromClipboard();
+
+
+#endif /* _Clipboard_H__ */
+
Index: /code/branches/network/src/util/Convert.h
===================================================================
--- /code/branches/network/src/util/Convert.h	(revision 1545)
+++ /code/branches/network/src/util/Convert.h	(revision 1545)
@@ -0,0 +1,634 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *      Fabian 'x3n' Landau
+ *   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 "SubString.h"
+#include "MultiTypeMath.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)
+    { 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<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)
+    {
+        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 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;
+    }
+};
+
+
+////////////////
+// MULTITYPES //
+////////////////
+
+// convert from MultiTypePrimitive
+template <class ToType>
+struct ConverterSpecialized<MultiTypePrimitive, ToType, _FromType_>
+{
+    enum { specialized = true };
+    static bool convert(ToType* output, const MultiTypePrimitive& input)
+    {
+        if (input.getType() == MT_void)
+            return ConvertValue(output, input.getVoid());
+        else if (input.getType() == MT_int)
+            return ConvertValue(output, input.getInt());
+        else if (input.getType() == MT_uint)
+            return ConvertValue(output, input.getUnsignedInt());
+        else if (input.getType() == MT_char)
+            return ConvertValue(output, input.getChar());
+        else if (input.getType() == MT_uchar)
+            return ConvertValue(output, input.getUnsignedChar());
+        else if (input.getType() == MT_short)
+            return ConvertValue(output, input.getShort());
+        else if (input.getType() == MT_ushort)
+            return ConvertValue(output, input.getUnsignedShort());
+        else if (input.getType() == MT_long)
+            return ConvertValue(output, input.getLong());
+        else if (input.getType() == MT_ulong)
+            return ConvertValue(output, input.getUnsignedLong());
+        else if (input.getType() == MT_float)
+            return ConvertValue(output, input.getFloat());
+        else if (input.getType() == MT_double)
+            return ConvertValue(output, input.getDouble());
+        else if (input.getType() == MT_longdouble)
+            return ConvertValue(output, input.getLongDouble());
+        else if (input.getType() == MT_bool)
+            return ConvertValue(output, input.getBool());
+        else
+            return false;
+    }
+};
+
+// convert from MultiTypeString
+template <class ToType>
+struct ConverterSpecialized<MultiTypeString, ToType, _FromType_>
+{
+    enum { specialized = true };
+    static bool convert(ToType* output, const MultiTypeString& input)
+    {
+        if (input.getType() == MT_constchar)
+            return ConvertValue(output, input.getConstChar());
+        else if (input.getType() == MT_string)
+            return ConvertValue(output, input.getString());
+        else
+            return ConvertValue(output, (MultiTypePrimitive)input);
+    }
+};
+
+// convert from MultiTypeMath
+template <class ToType>
+struct ConverterSpecialized<MultiTypeMath, ToType, _FromType_>
+{
+    enum { specialized = true };
+    static bool convert(ToType* output, const MultiTypeMath& input)
+    {
+        if (input.getType() == MT_vector2)
+            return ConvertValue(output, input.getVector2());
+        else if (input.getType() == MT_vector3)
+            return ConvertValue(output, input.getVector3());
+        else if (input.getType() == MT_vector4)
+            return ConvertValue(output, input.getVector4());
+        else if (input.getType() == MT_quaternion)
+            return ConvertValue(output, input.getQuaternion());
+        else if (input.getType() == MT_colourvalue)
+            return ConvertValue(output, input.getColourValue());
+        else if (input.getType() == MT_radian)
+            return ConvertValue(output, input.getRadian());
+        else if (input.getType() == MT_degree)
+            return ConvertValue(output, input.getDegree());
+        else
+            return ConvertValue(output, (MultiTypeString)input);
+    }
+};
+
+
+////////////////////
+// MATH TO STRING //
+////////////////////
+
+// 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 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() >= 4)
+        {
+            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 (!ConvertValue(&(output->a), tokens[3]))
+                return false;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif /* _Convert_H__ */
Index: /code/branches/network/src/util/ExprParser.cc
===================================================================
--- /code/branches/network/src/util/ExprParser.cc	(revision 1545)
+++ /code/branches/network/src/util/ExprParser.cc	(revision 1545)
@@ -0,0 +1,451 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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>
+
+// 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/network/src/util/ExprParser.h
===================================================================
--- /code/branches/network/src/util/ExprParser.h	(revision 1545)
+++ /code/branches/network/src/util/ExprParser.h	(revision 1545)
@@ -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/network/src/util/Math.cc
===================================================================
--- /code/branches/network/src/util/Math.cc	(revision 1545)
+++ /code/branches/network/src/util/Math.cc	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Math.h"
+
+/**
+    @brief Function for writing to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian)
+{
+    out << radian.valueRadians();
+    return out;
+}
+
+/**
+    @brief Function for reading from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
+{
+    float temp;
+    in >> temp;
+    radian = temp;
+    return in;
+}
+
+/**
+    @brief Function for writing to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+{
+    out << degree.valueDegrees();
+    return out;
+}
+
+/**
+    @brief Function for reading from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
+{
+    float temp;
+    in >> temp;
+    degree = temp;
+    return in;
+}
Index: /code/branches/network/src/util/Math.h
===================================================================
--- /code/branches/network/src/util/Math.h	(revision 1545)
+++ /code/branches/network/src/util/Math.h	(revision 1545)
@@ -0,0 +1,177 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 _Util_Math_H__
+#define _Util_Math_H__
+
+#include "UtilPrereqs.h"
+
+#include <ostream>
+
+#include <OgreMath.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector4.h>
+#include <OgreMatrix3.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::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);
+
+template <typename T>
+inline T sgn(T x)
+{
+    return (x >= 0) ? 1 : -1;
+}
+
+template <typename T>
+inline T min(T a, T b)
+{
+    return (a <= b) ? a : b;
+}
+
+template <typename T>
+inline T max(T a, T b)
+{
+    return (a >= b) ? a : b;
+}
+
+template <typename T>
+inline T clamp(T x, T min, T max)
+{
+    if (x < min)
+        return min;
+
+    if (x > max)
+        return max;
+
+    return x;
+}
+
+template <typename T>
+inline T square(T x)
+{
+    return x*x;
+}
+
+template <typename T>
+inline T cube(T x)
+{
+    return x*x*x;
+}
+
+template <typename T>
+inline int floor(T x)
+{
+    return (int)(x);
+}
+
+template <typename T>
+inline int ceil(T x)
+{
+    int temp = floor(x);
+    return (temp != x) ? (temp + 1) : temp;
+}
+
+template <typename T>
+inline int round(T x)
+{
+    return (int)(x + 0.5);
+}
+
+template <typename T>
+inline int mod(T x, int max)
+{
+    if (x >= 0)
+        return (x % max);
+    else
+        return ((x % max) + max);
+}
+
+template <typename T>
+T interpolate(float time, const T& start, const T& end)
+{
+    return time * (end - start) + start;
+}
+
+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;
+}
+
+inline _UtilExport float rnd()
+{
+    return ((float)rand() / RAND_MAX);
+}
+
+inline _UtilExport float rnd(float max)
+{
+    return rnd() * max;
+}
+
+inline _UtilExport float rnd(float min, float max)
+{
+    return rnd(max - min) + min;
+}
+
+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/network/src/util/MultiType.h
===================================================================
--- /code/branches/network/src/util/MultiType.h	(revision 1545)
+++ /code/branches/network/src/util/MultiType.h	(revision 1545)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ *   Inspiration: MultiType by Benjamin Grauer
+ */
+
+#ifndef _MultiType_H__
+#define _MultiType_H__
+
+#include "UtilPrereqs.h"
+
+enum _UtilExport MultiType
+{
+    MT_null,
+    MT_void,
+    MT_int,
+    MT_uint,
+    MT_char,
+    MT_uchar,
+    MT_short,
+    MT_ushort,
+    MT_long,
+    MT_ulong,
+    MT_float,
+    MT_double,
+    MT_longdouble,
+    MT_bool,
+    MT_constchar,
+    MT_string,
+    MT_xmlelement,
+    MT_vector2,
+    MT_vector3,
+    MT_vector4,
+    MT_colourvalue,
+    MT_quaternion,
+    MT_degree,
+    MT_radian
+};
+
+union _UtilExport MultiTypeValue
+{
+    void*           void_;
+    int             int_;
+    unsigned int    uint_;
+    char            char_;
+    unsigned char   uchar_;
+    short           short_;
+    unsigned short  ushort_;
+    long            long_;
+    unsigned long   ulong_;
+    float           float_;
+    double          double_;
+    long double     longdouble_;
+    bool            bool_;
+};
+
+#endif /* _MultiType_H__ */
Index: /code/branches/network/src/util/MultiTypeMath.cc
===================================================================
--- /code/branches/network/src/util/MultiTypeMath.cc	(revision 1545)
+++ /code/branches/network/src/util/MultiTypeMath.cc	(revision 1545)
@@ -0,0 +1,302 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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: MultiType by Benjamin Grauer
+ */
+
+#include "MultiTypeMath.h"
+#include "Convert.h"
+
+MultiTypeMath::MultiTypeMath(MultiType type) : MultiTypeString(type)
+{
+    if (type == MT_vector2)
+        this->vector2_ = orxonox::Vector2(0, 0);
+    else if (type == MT_vector3)
+        this->vector3_ = orxonox::Vector3(0, 0, 0);
+    else if (type == MT_vector4)
+        this->vector4_ = orxonox::Vector4(0, 0, 0, 0);
+    else if (type == MT_colourvalue)
+        this->colourvalue_ = orxonox::ColourValue(0, 0, 0, 0);
+    else if (type == MT_quaternion)
+        this->quaternion_ = orxonox::Quaternion(1, 0, 0, 0);
+    else if (type == MT_radian)
+        this->radian_ = orxonox::Radian(0);
+    else if (type == MT_degree)
+        this->degree_ = orxonox::Degree(0);
+}
+
+bool MultiTypeMath::operator==(const MultiTypeMath& mtm) const
+{
+    if (!MultiTypeString::operator==(mtm) && this->type_ == mtm.type_)
+    {
+        if (this->type_ == MT_vector2)
+            return (this->vector2_ == mtm.vector2_);
+        else if (this->type_ == MT_vector3)
+            return (this->vector3_ == mtm.vector3_);
+        else if (this->type_ == MT_vector4)
+            return (this->vector4_ == mtm.vector4_);
+        else if (this->type_ == MT_colourvalue)
+            return (this->colourvalue_ == mtm.colourvalue_);
+        else if (this->type_ == MT_quaternion)
+            return (this->quaternion_ == mtm.quaternion_);
+        else if (this->type_ == MT_radian)
+            return (this->radian_ == mtm.radian_);
+        else if (this->type_ == MT_degree)
+            return (this->degree_ == mtm.degree_);
+    }
+
+    return false;
+}
+
+bool MultiTypeMath::operator==(const MultiTypeString& mts) const
+{
+    return MultiTypeString::operator==(mts);
+}
+
+bool MultiTypeMath::operator==(const MultiTypePrimitive& mtp) const
+{
+    return MultiTypePrimitive::operator==(mtp);
+}
+
+bool MultiTypeMath::operator!=(const MultiTypeMath& mtm) const
+{
+    if (MultiTypeString::operator==(mtm) && this->type_ == mtm.type_)
+    {
+        if (this->type_ == MT_vector2)
+            return (this->vector2_ != mtm.vector2_);
+        else if (this->type_ == MT_vector3)
+            return (this->vector3_ != mtm.vector3_);
+        else if (this->type_ == MT_vector4)
+            return (this->vector4_ != mtm.vector4_);
+        else if (this->type_ == MT_colourvalue)
+            return (this->colourvalue_ != mtm.colourvalue_);
+        else if (this->type_ == MT_quaternion)
+            return (this->quaternion_ != mtm.quaternion_);
+        else if (this->type_ == MT_radian)
+            return (this->radian_ != mtm.radian_);
+        else if (this->type_ == MT_degree)
+            return (this->degree_ != mtm.degree_);
+    }
+
+    return true;
+}
+
+bool MultiTypeMath::operator!=(const MultiTypeString& mts) const
+{
+    return MultiTypeString::operator!=(mts);
+}
+
+bool MultiTypeMath::operator!=(const MultiTypePrimitive& mtp) const
+{
+    return MultiTypePrimitive::operator!=(mtp);
+}
+
+MultiTypeMath::operator void*() const
+{ return (this->type_ == MT_void) ? this->value_.void_ : getConvertedValue<MultiTypeMath, void*>(*this, 0); }
+MultiTypeMath::operator int() const
+{ return (this->type_ == MT_int) ? this->value_.int_ : getConvertedValue<MultiTypeMath, int>(*this, 0); }
+MultiTypeMath::operator unsigned int() const
+{ return (this->type_ == MT_uint) ? this->value_.uint_ : getConvertedValue<MultiTypeMath, unsigned int>(*this, 0); }
+MultiTypeMath::operator char() const
+{ return (this->type_ == MT_char) ? this->value_.char_ : getConvertedValue<MultiTypeMath, char>(*this, 0); }
+MultiTypeMath::operator unsigned char() const
+{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : getConvertedValue<MultiTypeMath, unsigned char>(*this, 0); }
+MultiTypeMath::operator short() const
+{ return (this->type_ == MT_short) ? this->value_.short_ : getConvertedValue<MultiTypeMath, short>(*this, 0); }
+MultiTypeMath::operator unsigned short() const
+{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : getConvertedValue<MultiTypeMath, unsigned short>(*this, 0); }
+MultiTypeMath::operator long() const
+{ return (this->type_ == MT_long) ? this->value_.long_ : getConvertedValue<MultiTypeMath, long>(*this, 0); }
+MultiTypeMath::operator unsigned long() const
+{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : getConvertedValue<MultiTypeMath, unsigned long>(*this, 0); }
+MultiTypeMath::operator float() const
+{ return (this->type_ == MT_float) ? this->value_.float_ : getConvertedValue<MultiTypeMath, float>(*this, 0); }
+MultiTypeMath::operator double() const
+{ return (this->type_ == MT_double) ? this->value_.double_ : getConvertedValue<MultiTypeMath, double>(*this, 0); }
+MultiTypeMath::operator long double() const
+{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : getConvertedValue<MultiTypeMath, long double>(*this, 0); }
+MultiTypeMath::operator bool() const
+{ return (this->type_ == MT_bool) ? this->value_.bool_ : getConvertedValue<MultiTypeMath, bool>(*this, 0); }
+MultiTypeMath::operator std::string() const
+{ return (this->type_ == MT_string) ? this->string_ : getConvertedValue<MultiTypeMath, std::string>(*this); }
+MultiTypeMath::operator const char*() const
+{ return ((this->type_ == MT_constchar) ? this->string_ : getConvertedValue<MultiTypeMath, std::string>(*this)).c_str(); }
+MultiTypeMath::operator orxonox::Vector2() const
+{ return (this->type_ == MT_vector2) ? this->vector2_ : getConvertedValue<MultiTypeMath, orxonox::Vector2>(*this); }
+MultiTypeMath::operator orxonox::Vector3() const
+{ return (this->type_ == MT_vector3) ? this->vector3_ : getConvertedValue<MultiTypeMath, orxonox::Vector3>(*this); }
+MultiTypeMath::operator orxonox::Vector4() const
+{ return (this->type_ == MT_vector4) ? this->vector4_ : getConvertedValue<MultiTypeMath, orxonox::Vector4>(*this); }
+MultiTypeMath::operator orxonox::Quaternion() const
+{ return (this->type_ == MT_quaternion) ? this->quaternion_ : getConvertedValue<MultiTypeMath, orxonox::Quaternion>(*this); }
+MultiTypeMath::operator orxonox::ColourValue() const
+{ return (this->type_ == MT_colourvalue) ? this->colourvalue_ : getConvertedValue<MultiTypeMath, orxonox::ColourValue>(*this); }
+MultiTypeMath::operator orxonox::Radian() const
+{ return (this->type_ == MT_radian) ? this->radian_ : getConvertedValue<MultiTypeMath, orxonox::Radian>(*this); }
+MultiTypeMath::operator orxonox::Degree() const
+{ return (this->type_ == MT_degree) ? this->degree_ : getConvertedValue<MultiTypeMath, orxonox::Degree>(*this); }
+
+void MultiTypeMath::setValue(const MultiTypeMath& mtm)
+{
+    MultiTypeString::setValue(mtm);
+    this->vector2_ = mtm.vector2_;
+    this->vector3_ = mtm.vector3_;
+    this->vector4_ = mtm.vector4_;
+    this->quaternion_ = mtm.quaternion_;
+    this->colourvalue_ = mtm.colourvalue_;
+    this->radian_ = mtm.radian_;
+    this->degree_ = mtm.degree_;
+}
+
+void MultiTypeMath::setValue(const MultiTypeString& mts)
+{
+    MultiTypeString::setValue(mts);
+}
+
+void MultiTypeMath::setValue(const MultiTypePrimitive& mtp)
+{
+    MultiTypePrimitive::setValue(mtp);
+}
+
+std::string MultiTypeMath::getTypename() const
+{
+    if (this->type_ == MT_vector2)
+        return "Vector2";
+    else if (this->type_ == MT_vector3)
+        return "Vector3";
+    else if (this->type_ == MT_vector4)
+        return "Vector4";
+    else if (this->type_ == MT_colourvalue)
+        return "ColourValue";
+    else if (this->type_ == MT_quaternion)
+        return "Quaternion";
+    else if (this->type_ == MT_radian)
+        return "Radian";
+    else if (this->type_ == MT_degree)
+        return "Degree";
+    else
+        return MultiTypeString::getTypename();
+}
+
+std::string MultiTypeMath::toString() const
+{
+    std::string output;
+
+    if (this->type_ == MT_vector2)
+        ConvertValue(&output, this->vector2_);
+    else if (this->type_ == MT_vector3)
+        ConvertValue(&output, this->vector3_);
+    else if (this->type_ == MT_vector4)
+        ConvertValue(&output, this->vector4_);
+    else if (this->type_ == MT_colourvalue)
+        ConvertValue(&output, this->colourvalue_);
+    else if (this->type_ == MT_quaternion)
+        ConvertValue(&output, this->quaternion_);
+    else if (this->type_ == MT_radian)
+        ConvertValue(&output, this->radian_);
+    else if (this->type_ == MT_degree)
+        ConvertValue(&output, this->degree_);
+    else
+        return MultiTypeString::toString();
+
+    return output;
+}
+
+bool MultiTypeMath::fromString(const std::string value)
+{
+    if (this->type_ == MT_vector2)
+        return ConvertValue(&this->vector2_, value, orxonox::Vector2(0, 0));
+    else if (this->type_ == MT_vector3)
+        return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0));
+    else if (this->type_ == MT_vector4)
+        return ConvertValue(&this->vector4_, value, orxonox::Vector4(0, 0, 0, 0));
+    else if (this->type_ == MT_colourvalue)
+        return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0));
+    else if (this->type_ == MT_quaternion)
+        return ConvertValue(&this->quaternion_, value, orxonox::Quaternion(1, 0, 0, 0));
+    else if (this->type_ == MT_radian)
+        return ConvertValue(&this->radian_, value, orxonox::Radian(0));
+    else if (this->type_ == MT_degree)
+        return ConvertValue(&this->degree_, value, orxonox::Degree(0));
+    else
+        return MultiTypeString::fromString(value);
+}
+
+bool MultiTypeMath::assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue)
+{
+    if (this->type_ == MT_void)
+        return ConvertValue(&this->value_.void_, mtm, defvalue.value_.void_);
+    else if (this->type_ == MT_int)
+        return ConvertValue(&this->value_.int_, mtm, defvalue.value_.int_);
+    else if (this->type_ == MT_uint)
+        return ConvertValue(&this->value_.uint_, mtm, defvalue.value_.uint_);
+    else if (this->type_ == MT_char)
+        return ConvertValue(&this->value_.char_, mtm, defvalue.value_.char_);
+    else if (this->type_ == MT_uchar)
+        return ConvertValue(&this->value_.uchar_, mtm, defvalue.value_.uchar_);
+    else if (this->type_ == MT_short)
+        return ConvertValue(&this->value_.short_, mtm, defvalue.value_.short_);
+    else if (this->type_ == MT_ushort)
+        return ConvertValue(&this->value_.ushort_, mtm, defvalue.value_.ushort_);
+    else if (this->type_ == MT_long)
+        return ConvertValue(&this->value_.long_, mtm, defvalue.value_.long_);
+    else if (this->type_ == MT_ulong)
+        return ConvertValue(&this->value_.ulong_, mtm, defvalue.value_.ulong_);
+    else if (this->type_ == MT_float)
+        return ConvertValue(&this->value_.float_, mtm, defvalue.value_.float_);
+    else if (this->type_ == MT_double)
+        return ConvertValue(&this->value_.double_, mtm, defvalue.value_.double_);
+    else if (this->type_ == MT_longdouble)
+        return ConvertValue(&this->value_.longdouble_, mtm, defvalue.value_.longdouble_);
+    else if (this->type_ == MT_bool)
+        return ConvertValue(&this->value_.bool_, mtm, defvalue.value_.bool_);
+    else if (this->type_ == MT_constchar)
+        return ConvertValue(&this->string_, mtm, defvalue.string_);
+    else if (this->type_ == MT_string)
+        return ConvertValue(&this->string_, mtm, defvalue.string_);
+    else if (this->type_ == MT_vector2)
+        return ConvertValue(&this->vector2_, mtm, defvalue.vector2_);
+    else if (this->type_ == MT_vector3)
+        return ConvertValue(&this->vector3_, mtm, defvalue.vector3_);
+    else if (this->type_ == MT_vector4)
+        return ConvertValue(&this->vector4_, mtm, defvalue.vector4_);
+    else if (this->type_ == MT_colourvalue)
+        return ConvertValue(&this->colourvalue_, mtm, defvalue.colourvalue_);
+    else if (this->type_ == MT_quaternion)
+        return ConvertValue(&this->quaternion_, mtm, defvalue.quaternion_);
+    else if (this->type_ == MT_radian)
+        return ConvertValue(&this->radian_, mtm, defvalue.radian_);
+    else if (this->type_ == MT_degree)
+        return ConvertValue(&this->degree_, mtm, defvalue.degree_);
+    else
+        return false;
+}
+
+std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm)
+{
+    out << mtm.toString();
+    return out;
+}
Index: /code/branches/network/src/util/MultiTypeMath.h
===================================================================
--- /code/branches/network/src/util/MultiTypeMath.h	(revision 1545)
+++ /code/branches/network/src/util/MultiTypeMath.h	(revision 1545)
@@ -0,0 +1,194 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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: MultiType by Benjamin Grauer
+ */
+
+#ifndef _MultiTypeMath_H__
+#define _MultiTypeMath_H__
+
+#include "UtilPrereqs.h"
+
+#include "MultiTypeString.h"
+#include "Math.h"
+
+// disable annoying warning about multiple assignment operators
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable:4522)
+#endif
+
+class _UtilExport MultiTypeMath : public MultiTypeString
+{
+    public:
+        MultiTypeMath(MultiType type = MT_null);
+        inline MultiTypeMath(void*          value) : MultiTypeString(value) {}
+        inline MultiTypeMath(int            value) : MultiTypeString(value) {}
+        inline MultiTypeMath(unsigned int   value) : MultiTypeString(value) {}
+        inline MultiTypeMath(char           value) : MultiTypeString(value) {}
+        inline MultiTypeMath(unsigned char  value) : MultiTypeString(value) {}
+        inline MultiTypeMath(short          value) : MultiTypeString(value) {}
+        inline MultiTypeMath(unsigned short value) : MultiTypeString(value) {}
+        inline MultiTypeMath(long           value) : MultiTypeString(value) {}
+        inline MultiTypeMath(unsigned long  value) : MultiTypeString(value) {}
+        inline MultiTypeMath(float          value) : MultiTypeString(value) {}
+        inline MultiTypeMath(double         value) : MultiTypeString(value) {}
+        inline MultiTypeMath(long double    value) : MultiTypeString(value) {}
+        inline MultiTypeMath(bool           value) : MultiTypeString(value) {}
+        inline MultiTypeMath(const char*             value) : MultiTypeString(value) {}
+        inline MultiTypeMath(const std::string&      value) : MultiTypeString(value) {}
+        inline MultiTypeMath(const orxonox::Vector2&     value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::Vector3&     value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::Vector4&     value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::Quaternion&  value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::Radian&      value) { this->setValue(value); }
+        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
+        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
+        inline MultiTypeMath(const MultiTypeString& mts)        { this->setValue(mts);   }
+        inline MultiTypeMath(const MultiTypePrimitive& mtp)     { this->setValue(mtp);   }
+        virtual inline ~MultiTypeMath() {}
+
+        using MultiTypeString::operator=;
+        inline MultiTypeMath& operator=(const orxonox::Vector2&     value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::Vector3&     value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::Vector4&     value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::Quaternion&  value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::Radian&      value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }
+        inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }
+        inline MultiTypeMath& operator=(const MultiTypeString& mts)        { this->setValue(mts);   return *this; }
+        inline MultiTypeMath& operator=(const MultiTypePrimitive mtp)      { this->setValue(mtp);   return *this; }
+
+        using MultiTypeString::operator==;
+        inline bool operator==(const orxonox::Vector2&     value) const { return (this->vector2_     == value); }
+        inline bool operator==(const orxonox::Vector3&     value) const { return (this->vector3_     == value); }
+        inline bool operator==(const orxonox::Vector4&     value) const { return (this->vector4_     == value); }
+        inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); }
+        inline bool operator==(const orxonox::Quaternion&  value) const { return (this->quaternion_  == value); }
+        inline bool operator==(const orxonox::Radian&      value) const { return (this->radian_      == value); }
+        inline bool operator==(const orxonox::Degree&      value) const { return (this->degree_      == value); }
+        bool operator==(const MultiTypeMath& mtm) const;
+        bool operator==(const MultiTypeString& mts) const;
+        bool operator==(const MultiTypePrimitive& mtp) const;
+
+        using MultiTypeString::operator!=;
+        inline bool operator!=(const orxonox::Vector2&     value) const { return (this->vector2_     != value); }
+        inline bool operator!=(const orxonox::Vector3&     value) const { return (this->vector3_     != value); }
+        inline bool operator!=(const orxonox::Vector4&     value) const { return (this->vector4_     != value); }
+        inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); }
+        inline bool operator!=(const orxonox::Quaternion&  value) const { return (this->quaternion_  != value); }
+        inline bool operator!=(const orxonox::Radian&      value) const { return (this->radian_      != value); }
+        inline bool operator!=(const orxonox::Degree&      value) const { return (this->degree_      != value); }
+        bool operator!=(const MultiTypeMath& mtm) const;
+        bool operator!=(const MultiTypeString& mts) const;
+        bool operator!=(const MultiTypePrimitive& mtp) const;
+
+        virtual operator void*()                const;
+        virtual operator int()                  const;
+        virtual operator unsigned int()         const;
+        virtual operator char()                 const;
+        virtual operator unsigned char()        const;
+        virtual operator short()                const;
+        virtual operator unsigned short()       const;
+        virtual operator long()                 const;
+        virtual operator unsigned long()        const;
+        virtual operator float ()               const;
+        virtual operator double ()              const;
+        virtual operator long double()          const;
+        virtual operator bool()                 const;
+        virtual operator std::string()          const;
+        virtual operator const char*()          const;
+        virtual operator orxonox::Vector2()     const;
+        virtual operator orxonox::Vector3()     const;
+        virtual operator orxonox::Vector4()     const;
+        virtual operator orxonox::ColourValue() const;
+        virtual operator orxonox::Quaternion()  const;
+        virtual operator orxonox::Radian()      const;
+        virtual operator orxonox::Degree()      const;
+
+        using MultiTypeString::setValue;
+        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
+        inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }
+        inline void setValue(const orxonox::Vector4&     value) { this->type_ = MT_vector4;     this->vector4_     = value; }
+        inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }
+        inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }
+        inline void setValue(const orxonox::Radian&      value) { this->type_ = MT_radian;      this->radian_      = value; }
+        inline void setValue(const orxonox::Degree&      value) { this->type_ = MT_degree;      this->degree_      = value; }
+        void setValue(const MultiTypeMath& mtm);
+        void setValue(const MultiTypeString& mts);
+        void setValue(const MultiTypePrimitive& mtp);
+
+        inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }
+        inline orxonox::Vector3     getVector3()     const { return this->vector3_;     }
+        inline orxonox::Vector4     getVector4()     const { return this->vector4_;     }
+        inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; }
+        inline orxonox::Quaternion  getQuaternion()  const { return this->quaternion_;  }
+        inline orxonox::Radian      getRadian()      const { return this->radian_;      }
+        inline orxonox::Degree      getDegree()      const { return this->degree_;      }
+
+        inline orxonox::Vector2&     getVector2()     { return this->vector2_;     }
+        inline orxonox::Vector3&     getVector3()     { return this->vector3_;     }
+        inline orxonox::Vector4&     getVector4()     { return this->vector4_;     }
+        inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; }
+        inline orxonox::Quaternion&  getQuaternion()  { return this->quaternion_;  }
+        inline orxonox::Radian&      getRadian()      { return this->radian_;      }
+        inline orxonox::Degree&      getDegree()      { return this->degree_;      }
+
+        using MultiTypeString::getValue;
+        inline void getValue(orxonox::Vector2*     variable) const { (*variable) = orxonox::Vector2     (this->vector2_);     }
+        inline void getValue(orxonox::Vector3*     variable) const { (*variable) = orxonox::Vector3     (this->vector3_);     }
+        inline void getValue(orxonox::Vector4*     variable) const { (*variable) = orxonox::Vector4     (this->vector4_);     }
+        inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); }
+        inline void getValue(orxonox::Quaternion*  variable) const { (*variable) = orxonox::Quaternion  (this->quaternion_);  }
+        inline void getValue(orxonox::Radian*      variable) const { (*variable) = orxonox::Radian      (this->radian_);      }
+        inline void getValue(orxonox::Degree*      variable) const { (*variable) = orxonox::Degree      (this->degree_);      }
+
+        virtual std::string getTypename() const;
+
+        virtual std::string toString() const;
+        virtual bool fromString(const std::string value);
+
+        virtual bool assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue = MultiTypeMath());
+
+    protected:
+        orxonox::Vector2      vector2_;
+        orxonox::Vector3      vector3_;
+        orxonox::Vector4      vector4_;
+        orxonox::ColourValue  colourvalue_;
+        orxonox::Quaternion   quaternion_;
+        orxonox::Radian       radian_;
+        orxonox::Degree       degree_;
+};
+
+_UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm);
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif /* _MultiTypeMath_H__ */
Index: /code/branches/network/src/util/MultiTypePrimitive.cc
===================================================================
--- /code/branches/network/src/util/MultiTypePrimitive.cc	(revision 1545)
+++ /code/branches/network/src/util/MultiTypePrimitive.cc	(revision 1545)
@@ -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: MultiType by Benjamin Grauer
+ */
+
+#include "MultiTypePrimitive.h"
+#include "Convert.h"
+
+MultiTypePrimitive::MultiTypePrimitive(MultiType type)
+{
+    this->type_ = type;
+
+    if (type == MT_void)
+        this->value_.void_ = 0;
+    else if (type == MT_int)
+        this->value_.int_ = 0;
+    else if (type == MT_uint)
+        this->value_.uint_ = 0;
+    else if (type == MT_char)
+        this->value_.char_ = 0;
+    else if (type == MT_uchar)
+        this->value_.uchar_ = 0;
+    else if (type == MT_short)
+        this->value_.short_ = 0;
+    else if (type == MT_ushort)
+        this->value_.ushort_ = 0;
+    else if (type == MT_long)
+        this->value_.long_ = 0;
+    else if (type == MT_ulong)
+        this->value_.ulong_ = 0;
+    else if (type == MT_float)
+        this->value_.float_ = 0.0;
+    else if (type == MT_double)
+        this->value_.double_ = 0.0;
+    else if (type == MT_longdouble)
+        this->value_.longdouble_ = 0.0;
+    else if (type == MT_bool)
+        this->value_.bool_ = false;
+    else
+        this->value_.void_ = 0;
+}
+
+bool MultiTypePrimitive::operator==(const MultiTypePrimitive& mtp) const
+{
+    if (this->type_ == mtp.type_)
+    {
+        if (this->type_ == MT_void)
+            return (this->value_.void_ == mtp.value_.void_);
+        else if (this->type_ == MT_int)
+            return (this->value_.int_ == mtp.value_.int_);
+        else if (this->type_ == MT_uint)
+            return (this->value_.uint_ == mtp.value_.uint_);
+        else if (this->type_ == MT_char)
+            return (this->value_.char_ == mtp.value_.char_);
+        else if (this->type_ == MT_uchar)
+            return (this->value_.uchar_ == mtp.value_.uchar_);
+        else if (this->type_ == MT_short)
+            return (this->value_.short_ == mtp.value_.short_);
+        else if (this->type_ == MT_ushort)
+            return (this->value_.ushort_ == mtp.value_.ushort_);
+        else if (this->type_ == MT_long)
+            return (this->value_.long_ == mtp.value_.long_);
+        else if (this->type_ == MT_ulong)
+            return (this->value_.ulong_ == mtp.value_.ulong_);
+        else if (this->type_ == MT_float)
+            return (this->value_.float_ == mtp.value_.float_);
+        else if (this->type_ == MT_double)
+            return (this->value_.double_ == mtp.value_.double_);
+        else if (this->type_ == MT_longdouble)
+            return (this->value_.longdouble_ == mtp.value_.longdouble_);
+        else if (this->type_ == MT_bool)
+            return (this->value_.bool_ == mtp.value_.bool_);
+    }
+
+    return false;
+}
+
+bool MultiTypePrimitive::operator!=(const MultiTypePrimitive& mtp) const
+{
+    if (this->type_ == mtp.type_)
+    {
+        if (this->type_ == MT_void)
+            return (this->value_.void_ != mtp.value_.void_);
+        else if (this->type_ == MT_int)
+            return (this->value_.int_ != mtp.value_.int_);
+        else if (this->type_ == MT_uint)
+            return (this->value_.uint_ != mtp.value_.uint_);
+        else if (this->type_ == MT_char)
+            return (this->value_.char_ != mtp.value_.char_);
+        else if (this->type_ == MT_uchar)
+            return (this->value_.uchar_ != mtp.value_.uchar_);
+        else if (this->type_ == MT_short)
+            return (this->value_.short_ != mtp.value_.short_);
+        else if (this->type_ == MT_ushort)
+            return (this->value_.ushort_ != mtp.value_.ushort_);
+        else if (this->type_ == MT_long)
+            return (this->value_.long_ != mtp.value_.long_);
+        else if (this->type_ == MT_ulong)
+            return (this->value_.ulong_ != mtp.value_.ulong_);
+        else if (this->type_ == MT_float)
+            return (this->value_.float_ != mtp.value_.float_);
+        else if (this->type_ == MT_double)
+            return (this->value_.double_ != mtp.value_.double_);
+        else if (this->type_ == MT_longdouble)
+            return (this->value_.longdouble_ != mtp.value_.longdouble_);
+        else if (this->type_ == MT_bool)
+            return (this->value_.bool_ != mtp.value_.bool_);
+    }
+
+    return true;
+}
+
+MultiTypePrimitive::operator void*() const
+{ return (this->type_ == MT_void) ? this->value_.void_ : getConvertedValue<MultiTypePrimitive, void*>(*this, 0); }
+MultiTypePrimitive::operator int() const
+{ return (this->type_ == MT_int) ? this->value_.int_ : getConvertedValue<MultiTypePrimitive, int>(*this, 0); }
+MultiTypePrimitive::operator unsigned int() const
+{ return (this->type_ == MT_uint) ? this->value_.uint_ : getConvertedValue<MultiTypePrimitive, unsigned int>(*this, 0); }
+MultiTypePrimitive::operator char() const
+{ return (this->type_ == MT_char) ? this->value_.char_ : getConvertedValue<MultiTypePrimitive, char>(*this, 0); }
+MultiTypePrimitive::operator unsigned char() const
+{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : getConvertedValue<MultiTypePrimitive, unsigned char>(*this, 0); }
+MultiTypePrimitive::operator short() const
+{ return (this->type_ == MT_short) ? this->value_.short_ : getConvertedValue<MultiTypePrimitive, short>(*this, 0); }
+MultiTypePrimitive::operator unsigned short() const
+{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : getConvertedValue<MultiTypePrimitive, unsigned short>(*this, 0); }
+MultiTypePrimitive::operator long() const
+{ return (this->type_ == MT_long) ? this->value_.long_ : getConvertedValue<MultiTypePrimitive, long>(*this, 0); }
+MultiTypePrimitive::operator unsigned long() const
+{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : getConvertedValue<MultiTypePrimitive, unsigned long>(*this, 0); }
+MultiTypePrimitive::operator float() const
+{ return (this->type_ == MT_float) ? this->value_.float_ : getConvertedValue<MultiTypePrimitive, float>(*this, 0); }
+MultiTypePrimitive::operator double() const
+{ return (this->type_ == MT_double) ? this->value_.double_ : getConvertedValue<MultiTypePrimitive, double>(*this, 0); }
+MultiTypePrimitive::operator long double() const
+{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : getConvertedValue<MultiTypePrimitive, long double>(*this, 0); }
+MultiTypePrimitive::operator bool() const
+{ return (this->type_ == MT_bool) ? this->value_.bool_ : getConvertedValue<MultiTypePrimitive, bool>(*this, 0); }
+
+void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp)
+{
+    this->type_ = mtp.type_;
+    this->value_ = mtp.value_;
+}
+
+std::string MultiTypePrimitive::getTypename() const
+{
+    if (this->type_ == MT_void)
+        return "pointer";
+    else if (this->type_ == MT_int)
+        return "int";
+    else if (this->type_ == MT_uint)
+        return "unsigned int";
+    else if (this->type_ == MT_char)
+        return "char";
+    else if (this->type_ == MT_uchar)
+        return "unsigned char";
+    else if (this->type_ == MT_short)
+        return "short";
+    else if (this->type_ == MT_ushort)
+        return "unsigned short";
+    else if (this->type_ == MT_long)
+        return "long";
+    else if (this->type_ == MT_ulong)
+        return "unsigned long";
+    else if (this->type_ == MT_float)
+        return "float";
+    else if (this->type_ == MT_double)
+        return "double";
+    else if (this->type_ == MT_longdouble)
+        return "long double";
+    else if (this->type_ == MT_bool)
+        return "bool";
+    else
+        return "unknown";
+}
+
+std::string MultiTypePrimitive::toString() const
+{
+    std::string output;
+
+    if (this->type_ == MT_void)
+        ConvertValue(&output, this->value_.void_);
+    else if (this->type_ == MT_int)
+        ConvertValue(&output, this->value_.int_);
+    else if (this->type_ == MT_uint)
+        ConvertValue(&output, this->value_.uint_);
+    else if (this->type_ == MT_char)
+        ConvertValue(&output, this->value_.char_);
+    else if (this->type_ == MT_uchar)
+        ConvertValue(&output, this->value_.uchar_);
+    else if (this->type_ == MT_short)
+        ConvertValue(&output, this->value_.short_);
+    else if (this->type_ == MT_ushort)
+        ConvertValue(&output, this->value_.ushort_);
+    else if (this->type_ == MT_long)
+        ConvertValue(&output, this->value_.long_);
+    else if (this->type_ == MT_ulong)
+        ConvertValue(&output, this->value_.ulong_);
+    else if (this->type_ == MT_float)
+        ConvertValue(&output, this->value_.float_);
+    else if (this->type_ == MT_double)
+        ConvertValue(&output, this->value_.double_);
+    else if (this->type_ == MT_longdouble)
+        ConvertValue(&output, this->value_.longdouble_);
+    else if (this->type_ == MT_bool)
+        ConvertValue(&output, this->value_.bool_);
+
+    return output;
+}
+
+bool MultiTypePrimitive::fromString(const std::string value)
+{
+    if (this->type_ == MT_void)
+        return ConvertValue(&this->value_.void_, value, (void*)0);
+    else if (this->type_ == MT_int)
+        return ConvertValue(&this->value_.int_, value, (int)0);
+    else if (this->type_ == MT_uint)
+        return ConvertValue(&this->value_.uint_, value, (unsigned int)0);
+    else if (this->type_ == MT_char)
+        return ConvertValue(&this->value_.char_, value, (char)0);
+    else if (this->type_ == MT_uchar)
+        return ConvertValue(&this->value_.uchar_, value, (unsigned char)0);
+    else if (this->type_ == MT_short)
+        return ConvertValue(&this->value_.short_, value, (short)0);
+    else if (this->type_ == MT_ushort)
+        return ConvertValue(&this->value_.ushort_, value, (unsigned short)0);
+    else if (this->type_ == MT_long)
+        return ConvertValue(&this->value_.long_, value, (long)0);
+    else if (this->type_ == MT_ulong)
+        return ConvertValue(&this->value_.ulong_, value, (unsigned long)0);
+    else if (this->type_ == MT_float)
+        return ConvertValue(&this->value_.float_, value, (float)0.0);
+    else if (this->type_ == MT_double)
+        return ConvertValue(&this->value_.double_, value, (double)0.0);
+    else if (this->type_ == MT_longdouble)
+        return ConvertValue(&this->value_.longdouble_, value, (long double)0.0);
+    else if (this->type_ == MT_bool)
+        return ConvertValue(&this->value_.bool_, value, false);
+    else
+        return false;
+}
+
+bool MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue)
+{
+    if (this->type_ == MT_void)
+        return ConvertValue(&this->value_.void_, mtp, defvalue.value_.void_);
+    else if (this->type_ == MT_int)
+        return ConvertValue(&this->value_.int_, mtp, defvalue.value_.int_);
+    else if (this->type_ == MT_uint)
+        return ConvertValue(&this->value_.uint_, mtp, defvalue.value_.uint_);
+    else if (this->type_ == MT_char)
+        return ConvertValue(&this->value_.char_, mtp, defvalue.value_.char_);
+    else if (this->type_ == MT_uchar)
+        return ConvertValue(&this->value_.uchar_, mtp, defvalue.value_.uchar_);
+    else if (this->type_ == MT_short)
+        return ConvertValue(&this->value_.short_, mtp, defvalue.value_.short_);
+    else if (this->type_ == MT_ushort)
+        return ConvertValue(&this->value_.ushort_, mtp, defvalue.value_.ushort_);
+    else if (this->type_ == MT_long)
+        return ConvertValue(&this->value_.long_, mtp, defvalue.value_.long_);
+    else if (this->type_ == MT_ulong)
+        return ConvertValue(&this->value_.ulong_, mtp, defvalue.value_.ulong_);
+    else if (this->type_ == MT_float)
+        return ConvertValue(&this->value_.float_, mtp, defvalue.value_.float_);
+    else if (this->type_ == MT_double)
+        return ConvertValue(&this->value_.double_, mtp, defvalue.value_.double_);
+    else if (this->type_ == MT_longdouble)
+        return ConvertValue(&this->value_.longdouble_, mtp, defvalue.value_.longdouble_);
+    else if (this->type_ == MT_bool)
+        return ConvertValue(&this->value_.bool_, mtp, defvalue.value_.bool_);
+    else
+        return false;
+
+}
+
+std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp)
+{
+    out << mtp.toString();
+    return out;
+}
Index: /code/branches/network/src/util/MultiTypePrimitive.h
===================================================================
--- /code/branches/network/src/util/MultiTypePrimitive.h	(revision 1545)
+++ /code/branches/network/src/util/MultiTypePrimitive.h	(revision 1545)
@@ -0,0 +1,198 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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: MultiType by Benjamin Grauer
+ */
+
+#ifndef _MultiTypePrimitive_H__
+#define _MultiTypePrimitive_H__
+
+#include "UtilPrereqs.h"
+
+#include <ostream>
+
+#include "MultiType.h"
+
+namespace orxonox
+{
+    class BaseObject;
+}
+class _UtilExport MultiTypePrimitive
+{
+    public:
+        MultiTypePrimitive(MultiType type = MT_null);
+        inline MultiTypePrimitive(void*          value) { this->setValue(value); }
+        inline MultiTypePrimitive(int            value) { this->setValue(value); }
+        inline MultiTypePrimitive(unsigned int   value) { this->setValue(value); }
+        inline MultiTypePrimitive(char           value) { this->setValue(value); }
+        inline MultiTypePrimitive(unsigned char  value) { this->setValue(value); }
+        inline MultiTypePrimitive(short          value) { this->setValue(value); }
+        inline MultiTypePrimitive(unsigned short value) { this->setValue(value); }
+        inline MultiTypePrimitive(long           value) { this->setValue(value); }
+        inline MultiTypePrimitive(unsigned long  value) { this->setValue(value); }
+        inline MultiTypePrimitive(float          value) { this->setValue(value); }
+        inline MultiTypePrimitive(double         value) { this->setValue(value); }
+        inline MultiTypePrimitive(long double    value) { this->setValue(value); }
+        inline MultiTypePrimitive(bool           value) { this->setValue(value); }
+        inline MultiTypePrimitive(const MultiTypePrimitive& mtp) { this->setValue(mtp); }
+        virtual inline ~MultiTypePrimitive() {}
+
+        inline MultiTypePrimitive& operator=(MultiType      value) { this->type_ = MT_null; return *this; }
+        inline MultiTypePrimitive& operator=(void*          value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(int            value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(unsigned int   value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(char           value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(unsigned char  value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(short          value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(unsigned short value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(long           value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(unsigned long  value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(float          value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(double         value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(long double    value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(bool           value) { this->setValue(value); return *this; }
+        inline MultiTypePrimitive& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp); return *this; }
+
+        inline bool operator==(void*          value) const { return (this->value_.void_       == value); }
+        inline bool operator==(int            value) const { return (this->value_.int_        == value); }
+        inline bool operator==(unsigned int   value) const { return (this->value_.uint_       == value); }
+        inline bool operator==(char           value) const { return (this->value_.char_       == value); }
+        inline bool operator==(unsigned char  value) const { return (this->value_.uchar_      == value); }
+        inline bool operator==(short          value) const { return (this->value_.short_      == value); }
+        inline bool operator==(unsigned short value) const { return (this->value_.ushort_     == value); }
+        inline bool operator==(long           value) const { return (this->value_.long_       == value); }
+        inline bool operator==(unsigned long  value) const { return (this->value_.ulong_      == value); }
+        inline bool operator==(float          value) const { return (this->value_.float_      == value); }
+        inline bool operator==(double         value) const { return (this->value_.double_     == value); }
+        inline bool operator==(long double    value) const { return (this->value_.longdouble_ == value); }
+        inline bool operator==(bool           value) const { return (this->value_.bool_       == value); }
+        bool operator==(const MultiTypePrimitive& mtp) const;
+
+        inline bool operator!=(void*          value) const { return (this->value_.void_       != value); }
+        inline bool operator!=(unsigned int   value) const { return (this->value_.uint_       != value); }
+        inline bool operator!=(char           value) const { return (this->value_.char_       != value); }
+        inline bool operator!=(unsigned char  value) const { return (this->value_.uchar_      != value); }
+        inline bool operator!=(short          value) const { return (this->value_.short_      != value); }
+        inline bool operator!=(unsigned short value) const { return (this->value_.ushort_     != value); }
+        inline bool operator!=(long           value) const { return (this->value_.long_       != value); }
+        inline bool operator!=(unsigned long  value) const { return (this->value_.ulong_      != value); }
+        inline bool operator!=(float          value) const { return (this->value_.float_      != value); }
+        inline bool operator!=(double         value) const { return (this->value_.double_     != value); }
+        inline bool operator!=(long double    value) const { return (this->value_.longdouble_ != value); }
+        inline bool operator!=(bool           value) const { return (this->value_.bool_       != value); }
+        bool operator!=(const MultiTypePrimitive& mtp) const;
+
+        template <class T>
+        operator T*()                     const
+        { return ((T*)this->value_.void_); }
+        virtual operator void*()          const;
+        virtual operator int()            const;
+        virtual operator unsigned int()   const;
+        virtual operator char()           const;
+        virtual operator unsigned char()  const;
+        virtual operator short()          const;
+        virtual operator unsigned short() const;
+        virtual operator long()           const;
+        virtual operator unsigned long()  const;
+        virtual operator float ()         const;
+        virtual operator double ()        const;
+        virtual operator long double()    const;
+        virtual operator bool()           const;
+
+        inline void setValue(void*          value) { this->type_ = MT_void;       this->value_.void_       = value; }
+        inline void setValue(int            value) { this->type_ = MT_int;        this->value_.int_        = value; }
+        inline void setValue(unsigned int   value) { this->type_ = MT_uint;       this->value_.uint_       = value; }
+        inline void setValue(char           value) { this->type_ = MT_char;       this->value_.char_       = value; }
+        inline void setValue(unsigned char  value) { this->type_ = MT_uchar;      this->value_.uchar_      = value; }
+        inline void setValue(short          value) { this->type_ = MT_short;      this->value_.short_      = value; }
+        inline void setValue(unsigned short value) { this->type_ = MT_ushort;     this->value_.ushort_     = value; }
+        inline void setValue(long           value) { this->type_ = MT_long;       this->value_.long_       = value; }
+        inline void setValue(unsigned long  value) { this->type_ = MT_ulong;      this->value_.ulong_      = value; }
+        inline void setValue(float          value) { this->type_ = MT_float;      this->value_.float_      = value; }
+        inline void setValue(double         value) { this->type_ = MT_double;     this->value_.double_     = value; }
+        inline void setValue(long double    value) { this->type_ = MT_longdouble; this->value_.longdouble_ = value; }
+        inline void setValue(bool           value) { this->type_ = MT_bool;       this->value_.bool_       = value; }
+        void setValue(const MultiTypePrimitive& mtp);
+
+        inline void*          getVoid()          const { return this->value_.void_;       }
+        inline int            getInt()           const { return this->value_.int_;        }
+        inline unsigned int   getUnsignedInt()   const { return this->value_.uint_;       }
+        inline char           getChar()          const { return this->value_.char_;       }
+        inline unsigned char  getUnsignedChar()  const { return this->value_.uchar_;      }
+        inline short          getShort()         const { return this->value_.short_;      }
+        inline unsigned short getUnsignedShort() const { return this->value_.ushort_;     }
+        inline long           getLong()          const { return this->value_.long_;       }
+        inline unsigned long  getUnsignedLong()  const { return this->value_.ulong_;      }
+        inline float          getFloat()         const { return this->value_.float_;      }
+        inline double         getDouble()        const { return this->value_.double_;     }
+        inline long double    getLongDouble()    const { return this->value_.longdouble_; }
+        inline bool           getBool()          const { return this->value_.bool_;       }
+
+        inline int&            getInt()           { return this->value_.int_;        }
+        inline unsigned int&   getUnsignedInt()   { return this->value_.uint_;       }
+        inline char&           getChar()          { return this->value_.char_;       }
+        inline unsigned char&  getUnsignedChar()  { return this->value_.uchar_;      }
+        inline short&          getShort()         { return this->value_.short_;      }
+        inline unsigned short& getUnsignedShort() { return this->value_.ushort_;     }
+        inline long&           getLong()          { return this->value_.long_;       }
+        inline unsigned long&  getUnsignedLong()  { return this->value_.ulong_;      }
+        inline float&          getFloat()         { return this->value_.float_;      }
+        inline double&         getDouble()        { return this->value_.double_;     }
+        inline long double&    getLongDouble()    { return this->value_.longdouble_; }
+        inline bool&           getBool()          { return this->value_.bool_;       }
+
+        inline void getValue(void*           variable) const { variable    = this->value_.void_;       }
+        inline void getValue(int*            variable) const { (*variable) = this->value_.int_;        }
+        inline void getValue(unsigned int*   variable) const { (*variable) = this->value_.uint_;       }
+        inline void getValue(char*           variable) const { (*variable) = this->value_.char_;       }
+        inline void getValue(unsigned char*  variable) const { (*variable) = this->value_.uchar_;      }
+        inline void getValue(short*          variable) const { (*variable) = this->value_.short_;      }
+        inline void getValue(unsigned short* variable) const { (*variable) = this->value_.ushort_;     }
+        inline void getValue(long*           variable) const { (*variable) = this->value_.long_;       }
+        inline void getValue(unsigned long*  variable) const { (*variable) = this->value_.ulong_;      }
+        inline void getValue(float*          variable) const { (*variable) = this->value_.float_;      }
+        inline void getValue(double*         variable) const { (*variable) = this->value_.double_;     }
+        inline void getValue(long double*    variable) const { (*variable) = this->value_.longdouble_; }
+        inline void getValue(bool*           variable) const { (*variable) = this->value_.bool_;       }
+
+        inline MultiType getType()           const { return this->type_; }
+        inline bool      isA(MultiType type) const { return (this->type_ == type); }
+
+        virtual std::string getTypename() const;
+
+        virtual std::string toString() const;
+        virtual bool fromString(const std::string value);
+
+        virtual bool assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue = MultiTypePrimitive());
+
+    protected:
+        MultiTypeValue  value_;
+        MultiType       type_;
+};
+
+_UtilExport std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp);
+
+#endif /* _MultiTypePrimitive_H__ */
Index: /code/branches/network/src/util/MultiTypeString.cc
===================================================================
--- /code/branches/network/src/util/MultiTypeString.cc	(revision 1545)
+++ /code/branches/network/src/util/MultiTypeString.cc	(revision 1545)
@@ -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:
+ *      ...
+ *
+ *   Inspiration: MultiType by Benjamin Grauer
+ */
+
+#include "MultiTypeString.h"
+#include "Convert.h"
+
+MultiTypeString::MultiTypeString(MultiType type) : MultiTypePrimitive(type)
+{
+    // Nothing to do for string
+}
+
+bool MultiTypeString::operator==(const MultiTypeString& mts) const
+{
+    if (!MultiTypePrimitive::operator==(mts) && this->type_ == mts.type_)
+    {
+        if (this->type_ == MT_constchar)
+            return (this->string_ == mts.string_);
+        else if (this->type_ == MT_string)
+            return (this->string_ == mts.string_);
+    }
+
+    return false;
+}
+
+bool MultiTypeString::operator==(const MultiTypePrimitive& mtp) const
+{
+    return MultiTypePrimitive::operator==(mtp);
+}
+
+bool MultiTypeString::operator!=(const MultiTypeString& mts) const
+{
+    if (MultiTypePrimitive::operator==(mts) && this->type_ == mts.type_)
+    {
+        if (this->type_ == MT_constchar)
+            return (this->string_ != mts.string_);
+        else if (this->type_ == MT_string)
+            return (this->string_ != mts.string_);
+    }
+
+    return true;
+}
+
+bool MultiTypeString::operator!=(const MultiTypePrimitive& mtp) const
+{
+    return MultiTypePrimitive::operator!=(mtp);
+}
+
+MultiTypeString::operator void*() const
+{ return (this->type_ == MT_void) ? this->value_.void_ : getConvertedValue<MultiTypeString, void*>(*this, 0); }
+MultiTypeString::operator int() const
+{ return (this->type_ == MT_int) ? this->value_.int_ : getConvertedValue<MultiTypeString, int>(*this, 0); }
+MultiTypeString::operator unsigned int() const
+{ return (this->type_ == MT_uint) ? this->value_.uint_ : getConvertedValue<MultiTypeString, unsigned int>(*this, 0); }
+MultiTypeString::operator char() const
+{ return (this->type_ == MT_char) ? this->value_.char_ : getConvertedValue<MultiTypeString, char>(*this, 0); }
+MultiTypeString::operator unsigned char() const
+{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : getConvertedValue<MultiTypeString, unsigned char>(*this, 0); }
+MultiTypeString::operator short() const
+{ return (this->type_ == MT_short) ? this->value_.short_ : getConvertedValue<MultiTypeString, short>(*this, 0); }
+MultiTypeString::operator unsigned short() const
+{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : getConvertedValue<MultiTypeString, unsigned short>(*this, 0); }
+MultiTypeString::operator long() const
+{ return (this->type_ == MT_long) ? this->value_.long_ : getConvertedValue<MultiTypeString, long>(*this, 0); }
+MultiTypeString::operator unsigned long() const
+{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : getConvertedValue<MultiTypeString, unsigned long>(*this, 0); }
+MultiTypeString::operator float() const
+{ return (this->type_ == MT_float) ? this->value_.float_ : getConvertedValue<MultiTypeString, float>(*this, 0); }
+MultiTypeString::operator double() const
+{ return (this->type_ == MT_double) ? this->value_.double_ : getConvertedValue<MultiTypeString, double>(*this, 0); }
+MultiTypeString::operator long double() const
+{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : getConvertedValue<MultiTypeString, long double>(*this, 0); }
+MultiTypeString::operator bool() const
+{ return (this->type_ == MT_bool) ? this->value_.bool_ : getConvertedValue<MultiTypeString, bool>(*this, 0); }
+MultiTypeString::operator std::string() const
+{ return (this->type_ == MT_string) ? this->string_ : getConvertedValue<MultiTypeString, std::string>(*this); }
+MultiTypeString::operator const char*() const
+{ return ((this->type_ == MT_constchar) ? this->string_ : getConvertedValue<MultiTypeString, std::string>(*this)).c_str(); }
+
+void MultiTypeString::setValue(const MultiTypeString& mts)
+{
+    MultiTypePrimitive::setValue(mts);
+    this->string_ = mts.string_;
+}
+
+void MultiTypeString::setValue(const MultiTypePrimitive& mtp)
+{
+    MultiTypePrimitive::setValue(mtp);
+}
+
+std::string MultiTypeString::getTypename() const
+{
+    if (this->type_ == MT_constchar)
+        return "string";
+    else if (this->type_ == MT_string)
+        return "string";
+    else
+        return MultiTypePrimitive::getTypename();
+}
+
+std::string MultiTypeString::toString() const
+{
+    std::string output;
+
+    if (this->type_ == MT_constchar)
+        return this->string_;
+    else if (this->type_ == MT_string)
+        return this->string_;
+    else
+        return MultiTypePrimitive::toString();
+
+    // FIXME: unreachable code
+    // return output;
+}
+
+bool MultiTypeString::fromString(const std::string value)
+{
+    if (this->type_ == MT_constchar)
+        this->string_ = value;
+    else if (this->type_ == MT_string)
+        this->string_ = value;
+    else
+        return MultiTypePrimitive::fromString(value);
+
+    return true;
+}
+
+bool MultiTypeString::assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue)
+{
+    if (this->type_ == MT_void)
+        return ConvertValue(&this->value_.void_, mts, defvalue.value_.void_);
+    else if (this->type_ == MT_int)
+        return ConvertValue(&this->value_.int_, mts, defvalue.value_.int_);
+    else if (this->type_ == MT_uint)
+        return ConvertValue(&this->value_.uint_, mts, defvalue.value_.uint_);
+    else if (this->type_ == MT_char)
+        return ConvertValue(&this->value_.char_, mts, defvalue.value_.char_);
+    else if (this->type_ == MT_uchar)
+        return ConvertValue(&this->value_.uchar_, mts, defvalue.value_.uchar_);
+    else if (this->type_ == MT_short)
+        return ConvertValue(&this->value_.short_, mts, defvalue.value_.short_);
+    else if (this->type_ == MT_ushort)
+        return ConvertValue(&this->value_.ushort_, mts, defvalue.value_.ushort_);
+    else if (this->type_ == MT_long)
+        return ConvertValue(&this->value_.long_, mts, defvalue.value_.long_);
+    else if (this->type_ == MT_ulong)
+        return ConvertValue(&this->value_.ulong_, mts, defvalue.value_.ulong_);
+    else if (this->type_ == MT_float)
+        return ConvertValue(&this->value_.float_, mts, defvalue.value_.float_);
+    else if (this->type_ == MT_double)
+        return ConvertValue(&this->value_.double_, mts, defvalue.value_.double_);
+    else if (this->type_ == MT_longdouble)
+        return ConvertValue(&this->value_.longdouble_, mts, defvalue.value_.longdouble_);
+    else if (this->type_ == MT_bool)
+        return ConvertValue(&this->value_.bool_, mts, defvalue.value_.bool_);
+    else if (this->type_ == MT_constchar)
+        return ConvertValue(&this->string_, mts, defvalue.string_);
+    else if (this->type_ == MT_string)
+        return ConvertValue(&this->string_, mts, defvalue.string_);
+    else
+        return false;
+}
+
+std::ostream& operator<<(std::ostream& out, MultiTypeString& mts)
+{
+    out << mts.toString();
+    return out;
+}
Index: /code/branches/network/src/util/MultiTypeString.h
===================================================================
--- /code/branches/network/src/util/MultiTypeString.h	(revision 1545)
+++ /code/branches/network/src/util/MultiTypeString.h	(revision 1545)
@@ -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:
+ *      ...
+ *
+ *   Inspiration: MultiType by Benjamin Grauer
+ */
+
+#ifndef _MultiTypeString_H__
+#define _MultiTypeString_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <iostream>
+
+#include "MultiTypePrimitive.h"
+
+// disable annoying warning about multiple assignment operators
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable:4522)
+#endif
+
+class _UtilExport MultiTypeString : public MultiTypePrimitive
+{
+    public:
+        MultiTypeString(MultiType type = MT_null);
+        inline MultiTypeString(void*          value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(int            value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(unsigned int   value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(char           value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(unsigned char  value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(short          value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(unsigned short value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(long           value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(unsigned long  value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(float          value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(double         value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
+        inline MultiTypeString(const char*             value) { this->setValue(value); }
+        inline MultiTypeString(const std::string&      value) { this->setValue(value); }
+        inline MultiTypeString(const MultiTypeString&    mts)  { this->setValue(mts);   }
+        inline MultiTypeString(const MultiTypePrimitive& mtp)  { this->setValue(mtp);   }
+        virtual inline ~MultiTypeString() {}
+
+        using MultiTypePrimitive::operator=;
+        inline MultiTypeString& operator=(const char*             value) { this->setValue(value); return *this; }
+        inline MultiTypeString& operator=(const std::string&      value) { this->setValue(value); return *this; }
+        inline MultiTypeString& operator=(const MultiTypeString&    mts) { this->setValue(mts);   return *this; }
+        inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp);   return *this; }
+
+        using MultiTypePrimitive::operator==;
+        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
+        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
+        bool operator==(const MultiTypeString&    mts) const;
+        bool operator==(const MultiTypePrimitive& mtp) const;
+
+        using MultiTypePrimitive::operator!=;
+        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
+        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
+        bool operator!=(const MultiTypeString&    mts) const;
+        bool operator!=(const MultiTypePrimitive& mtp) const;
+
+        virtual operator void*()          const;
+        virtual operator int()            const;
+        virtual operator unsigned int()   const;
+        virtual operator char()           const;
+        virtual operator unsigned char()  const;
+        virtual operator short()          const;
+        virtual operator unsigned short() const;
+        virtual operator long()           const;
+        virtual operator unsigned long()  const;
+        virtual operator float ()         const;
+        virtual operator double ()        const;
+        virtual operator long double()    const;
+        virtual operator bool()           const;
+        virtual operator std::string()    const;
+        virtual operator const char*()    const;
+
+        using MultiTypePrimitive::setValue;
+        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
+        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
+        void setValue(const MultiTypeString&    mts);
+        void setValue(const MultiTypePrimitive& mtp);
+
+        inline std::string getString()     const { return this->string_;         }
+        inline const char*  getConstChar() const { return this->string_.c_str(); }
+
+        inline std::string& getString()    { return this->string_;         }
+        inline const char*  getConstChar() { return this->string_.c_str(); }
+
+        using MultiTypePrimitive::getValue;
+        inline void getValue(std::string* variable) const { (*variable) = this->string_;         }
+        inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }
+
+        virtual std::string getTypename() const;
+
+        virtual std::string toString() const;
+        virtual bool fromString(const std::string value);
+
+        virtual bool assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue = MultiTypeString());
+
+    protected:
+        std::string      string_;
+};
+
+_UtilExport std::ostream& operator<<(std::ostream& out, MultiTypeString& mts);
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif /* _MultiTypeString_H__ */
Index: /code/branches/network/src/util/OrxonoxPlatform.h
===================================================================
--- /code/branches/network/src/util/OrxonoxPlatform.h	(revision 1545)
+++ /code/branches/network/src/util/OrxonoxPlatform.h	(revision 1545)
@@ -0,0 +1,282 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+/**
+ @file
+ @brief Various constants for compiler, architecture and platform. It's a mere
+        copy of the file found in the Ogre source code (OgrePlatform.h).
+ */
+
+#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
+
+// For generating compiler warnings - should work on any compiler
+// As a side note, if you start your message with 'Warning: ', the MSVC
+// IDE actually does catch a warning :)
+// FIXME: Try this on linux box. Doesn't work with msvc
+//#define ORXONOX_QUOTE_INPLACE(x) # x
+//#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x)
+//#define ORXONOX_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
+
+//----------------------------------------------------------------------------
+// Windows Settings
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+
+// Win32 compilers use _DEBUG for specifying debug builds.
+#  ifdef _DEBUG
+#    define ORXONOX_DEBUG_MODE 1
+#  else
+#    define ORXONOX_DEBUG_MODE 0
+#  endif
+
+// Disable unicode support on MingW at the moment, poorly supported in stdlibc++
+// STLPORT fixes this though so allow if found
+// MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h
+#  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
+
+// Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
+// specifying a debug build.
+// (??? this is wrong, on Linux debug builds aren't marked in any way unless
+// you mark it yourself any way you like it -- zap ???)
+#  ifdef DEBUG
+#    define ORXONOX_DEBUG_MODE 1
+#  else
+#    define ORXONOX_DEBUG_MODE 0
+#  endif
+
+/* FIXME: Check what this actually is and whether we need it or not
+#  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"
+#  else
+// ORXONOX_PLATFORM_LINUX
+#    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
+#  endif
+*/
+
+// Always enable unicode support for the moment
+// Perhaps disable in old versions of gcc if necessary
+#  define ORXONOX_UNICODE_SUPPORT 1
+
+#endif /* Patform Linux/Apple */
+
+//For apple, we always have a custom config.h file
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#  include "config.h"
+#endif
+
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// Endian Settings
+// check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly
+#ifdef ORXONOX_CONFIG_BIG_ENDIAN
+#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG
+#else
+#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE
+#endif
+
+//-----------------------------------------------------------------------
+// fixed width integers
+//-----------------------------------------------------------------------
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+typedef __int8            int8_t;
+typedef __int16           int16_t;
+typedef __int32           int32_t;
+typedef __int64           int64_t;
+typedef unsigned __int8   uint8_t;
+typedef unsigned __int16  uint16_t;
+typedef unsigned __int32  uint32_t;
+typedef unsigned __int64  uint64_t;
+#else
+# include "inttypes.h"
+#endif
+
+namespace orxonox {
+#ifdef ORXONOX_DOUBLE_PRECISION
+typedef double Real;
+#else
+typedef float Real;
+#endif
+}
+
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+// Turn off warnings generated by long std templates
+// This warns about truncation to 255 characters in debug/browse info
+//#   pragma warning (disable : 4786)
+
+// Turn off warnings generated by long std templates
+// This warns about truncation to 255 characters in debug/browse info
+//#   pragma warning (disable : 4503)
+
+// disable: conversion from 'double' to 'float', possible loss of data
+// disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
+// This has been dealt with in base_properties of the solution since the
+// warning primarily occurs in library header files (which are mostly
+// included before OrxonoxPlatform.h is)
+//#   pragma warning (disable : 4244)
+
+// disable: "conversion from 'size_t' to 'unsigned int', possible loss of data
+//#   pragma warning (disable : 4267)
+
+// disable: "truncation from 'double' to 'float'
+//#   pragma warning (disable : 4305)
+
+// set to level 4: "<type> needs to have dll-interface to be used by clients'
+// Happens on STL member variables which are not public therefore is ok
+#   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>
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */
+
+// include visual leak detector to search for memory leaks
+//#include <vld.h>
+
+#endif /* _OrxonoxPlatform_H__ */
Index: /code/branches/network/src/util/Sleep.h
===================================================================
--- /code/branches/network/src/util/Sleep.h	(revision 1545)
+++ /code/branches/network/src/util/Sleep.h	(revision 1545)
@@ -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  Sleep.h
+ @brief Macros for using sleep() and usleep() under windows
+ */
+
+#include "UtilPrereqs.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
+#  include <unistd.h>
+inline void msleep(unsigned long msec)
+{
+  usleep(msec * 1000);
+}
+#endif
Index: /code/branches/network/src/util/String.cc
===================================================================
--- /code/branches/network/src/util/String.cc	(revision 1545)
+++ /code/branches/network/src/util/String.cc	(revision 1545)
@@ -0,0 +1,462 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#include "String.h"
+
+#include <cctype>
+#include <iostream>
+
+/**
+    @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;
+}
+
+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;
+}
+
+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/network/src/util/String.h
===================================================================
--- /code/branches/network/src/util/String.h	(revision 1545)
+++ /code/branches/network/src/util/String.h	(revision 1545)
@@ -0,0 +1,166 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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
+ *
+ */
+
+#ifndef _Util_String_H__
+#define _Util_String_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+
+_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);
+
+//! The Convert class has some static member functions to convert strings to values and values to strings.
+class _UtilExport Convert
+{
+    public:
+        /**
+            @brief Converts a value of any type to a string.
+            @param output The string to write the result in
+            @param input The variable to convert
+            @return True if the conversion succeded
+
+            @example
+            float f = 3.14;
+            std::string output;
+            bool success = Convert::ToString(&output, f);
+        */
+        template <typename T>
+        static bool ToString(std::string* output, T input)
+        {
+            std::ostringstream oss;
+            if (oss << input)
+            {
+                (*output) = oss.str();
+                return true;
+            }
+
+            return false;
+        }
+
+        /**
+            @brief Converts a value of any type to a string and assigns a defaultvalue if the conversion fails.
+            @param output The string to write the result in
+            @param input The variable to convert
+            @param fallbackString The assigned string if the conversion fails.
+            @return True if the conversion succeeded
+
+            @example
+            float f = 3.14;
+            std::string output;
+            bool success = Convert::ToString(&output, f, "0.000000");
+        */
+        template <typename T>
+        static bool ToString(std::string* output, T input, const std::string& fallbackString)
+        {
+            if (Convert::ToString(output, input))
+                return true;
+
+            (*output) = fallbackString;
+            return false;
+        }
+
+        /**
+            @brief Converts a string to a value of any type.
+            @param output The variable to assign the result to
+            @param input The string to convert
+            @return True if the conversion succeeded
+
+            @example
+            std::string input = "3.14";
+            float f;
+            bool success = string2Number(&f, input);
+        */
+        template <typename T>
+        static bool FromString(T* output, const std::string& input)
+        {
+            std::istringstream iss(input);
+            if (iss >> (*output))
+                return true;
+
+            return false;
+        }
+
+        /**
+            @brief Converts a string to a value of any type.
+            @param output The variable to assign the result to
+            @param input The string to convert
+            @param fallbackValue The assigned value if the conversion fails
+            @return True if the conversion succeeded
+
+            @example
+            std::string input = "3.14";
+            float f;
+            bool success = string2Number(&f, input, 0.000000);
+        */
+        template <typename T>
+        static bool FromString(T* output, const std::string& input, T fallbackValue)
+        {
+            if (Convert::FromString(output, input))
+                return true;
+
+            (*output) = fallbackValue;
+            return false;
+        }
+};
+
+#endif /* _Util_String_H__ */
Index: /code/branches/network/src/util/SubString.cc
===================================================================
--- /code/branches/network/src/util/SubString.cc	(revision 1545)
+++ /code/branches/network/src/util/SubString.cc	(revision 1545)
@@ -0,0 +1,557 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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.
+//
+ */
+
+#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/network/src/util/SubString.h
===================================================================
--- /code/branches/network/src/util/SubString.h	(revision 1545)
+++ /code/branches/network/src/util/SubString.h	(revision 1545)
@@ -0,0 +1,171 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   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 with 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 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/network/src/util/UtilPrereqs.h
===================================================================
--- /code/branches/network/src/util/UtilPrereqs.h	(revision 1545)
+++ /code/branches/network/src/util/UtilPrereqs.h	(revision 1545)
@@ -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:
+ *      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 MultiTypePrimitive;
+class MultiTypeString;
+class MultiTypeMath;
+template <class T>
+class String2Number;
+class SubString;
+
+#endif /* _UtilPrereqs_H__ */
Index: /code/branches/network/src/util/XMLIncludes.h
===================================================================
--- /code/branches/network/src/util/XMLIncludes.h	(revision 1545)
+++ /code/branches/network/src/util/XMLIncludes.h	(revision 1545)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#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/network/src/util/testing/CMakeLists.txt
===================================================================
--- /code/branches/network/src/util/testing/CMakeLists.txt	(revision 1545)
+++ /code/branches/network/src/util/testing/CMakeLists.txt	(revision 1545)
@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
+	../
+)
+
+ADD_EXECUTABLE(TestConverter
+ TestConverter.cpp
+)
+
+
+ADD_TEST(TestConverter
+	${EXECUTABLE_OUTPUT_PATH}/TestConverter
+)
Index: /code/branches/network/src/util/testing/TestConverter.cpp
===================================================================
--- /code/branches/network/src/util/testing/TestConverter.cpp	(revision 1545)
+++ /code/branches/network/src/util/testing/TestConverter.cpp	(revision 1545)
@@ -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/network/updateMedia.sh
===================================================================
--- /code/branches/network/updateMedia.sh	(revision 1545)
+++ /code/branches/network/updateMedia.sh	(revision 1545)
@@ -0,0 +1,5 @@
+#!/bin/bash
+dir=${pwd}
+cd ../Media
+svn up
+cd $dir
Index: /code/branches/network/visual_studio/audio_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/audio_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/audio_properties.vsprops	(revision 1545)
@@ -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$(CSS).lib alut$(CS).lib OpenAL32$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/base_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/base_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/base_properties.vsprops	(revision 1545)
@@ -0,0 +1,45 @@
+<?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)src&quot;;&quot;$(RootDir)src\orxonox&quot;;&quot;$(RootDir)src\tolua&quot;;&quot;$(RootDir)src\ois&quot;;&quot;$(DependencyDir)include&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)..\dependencies\"
+	/>
+	<UserMacro
+		Name="CS"
+		Value=""
+	/>
+	<UserMacro
+		Name="CSS"
+		Value=""
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/base_properties_debug.vsprops
===================================================================
--- /code/branches/network/visual_studio/base_properties_debug.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/base_properties_debug.vsprops	(revision 1545)
@@ -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/network/visual_studio/base_properties_release.vsprops
===================================================================
--- /code/branches/network/visual_studio/base_properties_release.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/base_properties_release.vsprops	(revision 1545)
@@ -0,0 +1,31 @@
+<?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"
+		WholeProgramOptimization="false"
+		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/network/visual_studio/core_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/core_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/core_properties.vsprops	(revision 1545)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="core_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="CORE_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CSS).lib lua-5.1$(CS).lib tcl85t.lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/cpptcl_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/cpptcl_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/cpptcl_properties.vsprops	(revision 1545)
@@ -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/network/visual_studio/directory_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/directory_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/directory_properties.vsprops	(revision 1545)
@@ -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/network/visual_studio/network_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/network_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/network_properties.vsprops	(revision 1545)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="network_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		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/network/visual_studio/orxonox_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/orxonox_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/orxonox_properties.vsprops	(revision 1545)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="orxonox_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet$(CS).lib zlib$(CS).lib"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
+		IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/orxonox_vc8.sln
===================================================================
--- /code/branches/network/visual_studio/orxonox_vc8.sln	(revision 1545)
+++ /code/branches/network/visual_studio/orxonox_vc8.sln	(revision 1545)
@@ -0,0 +1,156 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "vc8\audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "vc8\core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E} = {9CC704CB-4956-4479-BDEC-57CBC03F700E}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "vc8\network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "orxonox", "vc8\orxonox.vcproj", "{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+	ProjectSection(ProjectDependencies) = postProject
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
+		{4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+		{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}
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "vc8\util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tixml", "vc8\tixml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "vc8\tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ois", "vc8\ois.vcproj", "{9CC704CB-4956-4479-BDEC-57CBC03F700E}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "vc8\cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
+	ProjectSection(WebsiteProperties) = preProject
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.Debug = "False"
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+		static_libs_debug|Win32 = static_libs_debug|Win32
+		static_libs_release|Win32 = static_libs_release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{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
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.static_libs_release|Win32.ActiveCfg = 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
+		{271715F3-5B90-4110-A552-70C788084A86}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.static_libs_release|Win32.ActiveCfg = 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
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.static_libs_release|Win32.ActiveCfg = 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
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.static_libs_release|Win32.ActiveCfg = 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
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.static_libs_release|Win32.ActiveCfg = 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
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_debug|Win32.ActiveCfg = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_debug|Win32.Build.0 = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_release|Win32.ActiveCfg = Release|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.static_libs_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
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_debug|Win32.ActiveCfg = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_debug|Win32.Build.0 = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_release|Win32.ActiveCfg = Release|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.static_libs_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
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.static_libs_debug|Win32.Build.0 = Release|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.static_libs_release|Win32.ActiveCfg = Release|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.static_libs_release|Win32.Build.0 = Release|Win32
+		{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
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.static_libs_debug|Win32.ActiveCfg = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.static_libs_debug|Win32.Build.0 = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.static_libs_release|Win32.ActiveCfg = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.static_libs_release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /code/branches/network/visual_studio/tixml_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/tixml_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/tixml_properties.vsprops	(revision 1545)
@@ -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/network/visual_studio/tolua_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/tolua_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/tolua_properties.vsprops	(revision 1545)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		DisableSpecificWarnings="4996"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/util_properties.vsprops
===================================================================
--- /code/branches/network/visual_studio/util_properties.vsprops	(revision 1545)
+++ /code/branches/network/visual_studio/util_properties.vsprops	(revision 1545)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="util_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="UTIL_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CSS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/network/visual_studio/vc8/audio.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/audio.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/audio.vcproj	(revision 1545)
@@ -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="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>
+	</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/network/visual_studio/vc8/core.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/core.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/core.vcproj	(revision 1545)
@@ -0,0 +1,564 @@
+<?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="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>
+	</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\ConfigFileManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueContainer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Core.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Error.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OutputBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OutputHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Script.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\SignalHandler.cc"
+				>
+			</File>
+			<Filter
+				Name="tolua"
+				>
+				<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\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>
+			</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\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>
+			</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\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\Debug.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Error.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OutputBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OutputHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Script.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Script_clean.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\SignalHandler.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\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\KeyBinder.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyDetector.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\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\MetaObjectList.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectList.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/network/visual_studio/vc8/cpptcl.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/cpptcl.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/cpptcl.vcproj	(revision 1545)
@@ -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="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>
+	</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/network/visual_studio/vc8/network.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/network.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/network.vcproj	(revision 1545)
@@ -0,0 +1,334 @@
+<?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="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>
+	</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\dummyclient.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\network\dummyclient2.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\network\dummyclient3.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\network\dummyserver.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\network\dummyserver3.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GameStateClient.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GameStateManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketDecoder.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketGenerator.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.cc"
+				>
+			</File>
+		</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\GameStateManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\NetworkPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketTypes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/network/visual_studio/vc8/ois.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/ois.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/ois.vcproj	(revision 1545)
@@ -0,0 +1,815 @@
+<?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"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				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"
+				LinkTimeCodeGeneration="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"
+				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/network/visual_studio/vc8/orxonox.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/orxonox.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/orxonox.vcproj	(revision 1545)
@@ -0,0 +1,646 @@
+<?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="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>
+	</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\Orxonox.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\Settings.cc"
+				>
+			</File>
+			<Filter
+				Name="hud"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\hud\BarOverlayElement.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\HUD.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\Navigation.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\RadarObject.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\RadarOverlayElement.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Ambient.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Camera.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Explosion.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Model.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\NPC.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
+					Name="weapon"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\AmmunitionDump.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BarrelGun.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BaseWeapon.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\Bullet.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BulletManager.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\WeaponStation.cc"
+						>
+						<FileConfiguration
+							Name="Debug|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+						<FileConfiguration
+							Name="Release|Win32"
+							ExcludedFromBuild="true"
+							>
+							<Tool
+								Name="VCCLCompilerTool"
+							/>
+						</FileConfiguration>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="particle"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\particle\ParticleInterface.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\Timer.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="console"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\console\InGameConsole.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<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>
+		<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\Orxonox.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxStableHeaders.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Settings.h"
+				>
+			</File>
+			<Filter
+				Name="hud"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\hud\BarOverlayElement.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\HUD.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\Navigation.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\OverlayElementFactories.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\RadarObject.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\hud\RadarOverlayElement.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Ambient.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Camera.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Explosion.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Model.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\NPC.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
+					Name="weapon"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\AmmunitionDump.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BarrelGun.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BaseWeapon.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\Bullet.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\BulletManager.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\objects\weapon\WeaponStation.h"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="particle"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\particle\ParticleInterface.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\Timer.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="console"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\console\InGameConsole.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua_bind.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/network/visual_studio/vc8/tixml.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/tixml.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/tixml.vcproj	(revision 1545)
@@ -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="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>
+	</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/network/visual_studio/vc8/tolua.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/tolua.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/tolua.vcproj	(revision 1545)
@@ -0,0 +1,170 @@
+<?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="4"
+			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="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;..\tolua_properties.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="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>
+	</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/network/visual_studio/vc8/util.vcproj
===================================================================
--- /code/branches/network/visual_studio/vc8/util.vcproj	(revision 1545)
+++ /code/branches/network/visual_studio/vc8/util.vcproj	(revision 1545)
@@ -0,0 +1,256 @@
+<?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="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>
+	</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\ArgReader.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Clipboard.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeMath.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypePrimitive.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeString.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\ArgReader.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Clipboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Convert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiType.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeMath.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypePrimitive.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeString.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OrxonoxPlatform.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>
