Index: code/branches/pch/bin/CMakeLists.txt
===================================================================
--- code/branches/pch/bin/CMakeLists.txt	(revision 3166)
+++ code/branches/pch/bin/CMakeLists.txt	(revision 3167)
@@ -33,11 +33,13 @@
   ENDFOREACH(_script)
 ENDIF()
+# Also copy vld.ini (visual leak detector config) for MSVC
+IF(MSVC)
+  LIST(APPEND RUN_SCRIPTS vld.ini)
+ENDIF()
 
 IF(NOT CMAKE_CONFIGURATION_TYPES)
   SET(_subdirs .)
-  SEt(_default_subdir .)
 ELSE()
   SET(_subdirs ${CMAKE_CONFIGURATION_TYPES})
-  SEt(_default_subdir Debug)
 ENDIF()
 STRING(REPLACE "/" "\\" ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY})
@@ -51,8 +53,4 @@
   FOREACH(_script ${RUN_SCRIPTS})
     CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${_script}.in ${CURRENT_RUNTIME_DIR}/${_script} @ONLY)
-    IF(_subdir STREQUAL _default_subdir)
-      # Convenience script to be used when sitting in the binary directory. Defaults to Debug for msvc.
-      CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${_script}.in ${CMAKE_BINARY_DIR}/${_script} @ONLY)
-    ENDIF()
   ENDFOREACH(_script)
 
Index: code/branches/pch/bin/vld.ini.in
===================================================================
--- code/branches/pch/bin/vld.ini.in	(revision 3167)
+++ code/branches/pch/bin/vld.ini.in	(revision 3167)
@@ -0,0 +1,155 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;  Visual Leak Detector - Initialization/Configuration File
+;;  Copyright (c) 2006 Dan Moulding
+;;
+;;  This library is free software; you can redistribute it and/or
+;;  modify it under the terms of the GNU Lesser General Public
+;;  License as published by the Free Software Foundation; either
+;;  version 2.1 of the License, or (at your option) any later version.
+;;
+;;  This library is distributed in the hope that it will be useful,
+;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;  Lesser General Public License for more details.
+;;
+;;  You should have received a copy of the GNU Lesser General Public
+;;  License along with this library; if not, write to the Free Software
+;;  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+;;
+;;  See COPYING.txt for the full terms of the GNU Lesser General Public License.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; Any options left blank or not present will revert to their default values.
+[Options]
+
+; The main on/off switch. If off, Visual Leak Detector will be completely
+; disabled. It will do nothing but print a message to the debugger indicating
+; that it has been turned off.
+;
+;  Valid Values: on, off
+;  Default: on
+;
+VLD = @VISUAL_LEAK_DETECTOR_ENABLE@ 
+
+; If yes, duplicate leaks (those that are identical) are not shown individually.
+; Only the first such leak is shown, along with a number indicating the total
+; number of duplicate leaks.
+;
+;   Valid Values: yes, no
+;   Default: no
+;
+AggregateDuplicates = yes
+
+; Lists any additional modules to be included in memory leak detection. This can
+; be useful for checking for memory leaks in debug builds of 3rd party modules
+; which can not be easily rebuilt with '#include "vld.h"'. This option should be
+; used only if absolutely necessary and only if you really know what you are
+; doing.
+;
+;   CAUTION: Avoid listing any modules that link with the release CRT libraries.
+;     Only modules that link with the debug CRT libraries should be listed here.
+;     Doing otherwise might result in false memory leak reports or even crashes.
+;
+;   Valid Values: Any list containing module names (i.e. names of EXEs or DLLs).
+;   Default: None.
+;
+ForceIncludeModules =
+
+; Maximum number of data bytes to display for each leaked block. If zero, then
+; the data dump is completely suppressed and only call stacks are shown.
+; Limiting this to a low number can be useful if any of the leaked blocks are
+; very large and cause unnecessary clutter in the memory leak report.
+;
+;   Value Values: 0 - 4294967295
+;   Default: 4294967295
+;
+MaxDataDump = 
+
+; Maximum number of call stack frames to trace back during leak detection.
+; Limiting this to a low number can reduce the CPU utilization overhead imposed
+; by memory leak detection, especially when using the slower "safe" stack
+; walking method (see StackWalkMethod below).
+;
+;   Valid Values: 1 - 4294967295
+;   Default: 4294967295
+;
+MaxTraceFrames = 
+
+; Sets the type of encoding to use for the generated memory leak report. This
+; option is really only useful in conjuction with sending the report to a file.
+; Sending a Unicode encoded report to the debugger is not useful because the
+; debugger cannot display Unicode characters. Using Unicode encoding might be
+; useful if the data contained in leaked blocks is likely to consist of Unicode
+; text.
+;
+;   Valid Values: ascii, unicode
+;   Default: ascii
+;
+ReportEncoding = ascii
+
+; Sets the report file destination, if reporting to file is enabled. A relative
+; path may be specified and is considered relative to the process' working
+; directory.
+;
+;   Valid Values: Any valid path and filename.
+;   Default: .\memory_leak_report.txt
+;
+ReportFile = 
+
+; Sets the report destination to either a file, the debugger, or both. If
+; reporting to file is enabled, the report is sent to the file specified by the
+; ReportFile option.
+;
+;   Valid Values: debugger, file, both
+;   Default: debugger
+;
+ReportTo = debugger
+
+; Turns on or off a self-test mode which is used to verify that VLD is able to
+; detect memory leaks in itself. Intended to be used for debugging VLD itself,
+; not for debugging other programs.
+;
+;   Valid Values: on, off
+;   Default: off
+;
+SelfTest = off
+
+; Selects the method to be used for walking the stack to obtain stack traces for
+; allocated memory blocks. The "fast" method may not always be able to
+; successfully trace completely through all call stacks. In such cases, the
+; "safe" method may prove to more reliably obtain the full stack trace. The
+; disadvantage is that the "safe" method is significantly slower than the "fast"
+; method and will probably result in very noticeable performance degradation of
+; the program being debugged.
+;
+;   Valid Values: fast, safe
+;   Default: fast
+; 
+StackWalkMethod = fast
+
+; Determines whether memory leak detection should be initially enabled for all
+; threads, or whether it should be initially disabled for all threads. If set
+; to "yes", then any threads requiring memory leak detection to be enabled will
+; need to call VLDEnable at some point to enable leak detection for those
+; threads.
+;
+;   Valid Values: yes, no
+;   Default: no
+;
+StartDisabled = no
+
+; Determines whether or not all frames, including frames internal to the heap,
+; are traced. There will always be a number of frames internal to Visual Leak
+; Detector and C/C++ or Win32 heap APIs that aren't generally useful for
+; determining the cause of a leak. Normally these frames are skipped during the
+; stack trace, which somewhat reduces the time spent tracing and amount of data
+; collected and stored in memory. Including all frames in the stack trace, all
+; the way down into VLD's own code can, however, be useful for debugging VLD
+; itself.
+;
+;   Valid Values: yes, no
+;   Default: no
+;
+TraceInternalFrames = no
Index: code/branches/pch/cmake/BuildConfig.cmake
===================================================================
--- code/branches/pch/cmake/BuildConfig.cmake	(revision 3166)
+++ code/branches/pch/cmake/BuildConfig.cmake	(revision 3167)
@@ -70,4 +70,9 @@
 ENDIF()
 
+# Enable expensive optimisations: Use this for a binary release build
+OPTION(ORXONOX_RELEASE "Enable when building restributable releases" FALSE)
+
+# Use WinMain() or main()?
+OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE)
 
 ################# OGRE Plugins ##################
Index: code/branches/pch/cmake/BuildConfigMSVC.cmake
===================================================================
--- code/branches/pch/cmake/BuildConfigMSVC.cmake	(revision 3166)
+++ code/branches/pch/cmake/BuildConfigMSVC.cmake	(revision 3167)
@@ -34,7 +34,14 @@
 ######################## Options ########################
 
-IF(MSVC80)
-  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" FALSE)
-ENDIF(MSVC80)
+# Currently VLD has a problem with MSVC9 although it actually is supported
+IF(MSVC8)
+  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
+ENDIF()
+# Make sure the value is "on" or "off" for vld.ini
+IF(VISUAL_LEAK_DETECTOR_ENABLE)
+  SET(VISUAL_LEAK_DETECTOR_ENABLE on)
+ELSE()
+  SET(VISUAL_LEAK_DETECTOR_ENABLE off)
+ENDIF()
 
 # Orxonox only supports MSVC 8 and above, which gets asserted above
@@ -61,5 +68,5 @@
 
 # Overwrite CMake default flags here.
-SET_COMPILER_FLAGS("-MDd -Od -ZI -D_DEBUG -Gm -RTC1" Debug          CACHE)
+SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -Gm -RTC1" Debug          CACHE)
 SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE)
 SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"      RelWithDebInfo CACHE)
@@ -89,4 +96,5 @@
 # Happens on STL member variables which are not public
 ADD_COMPILER_FLAGS("-w44251" CACHE)
+ADD_COMPILER_FLAGS("-w44275" CACHE) # For inheritance
 
 # Multiple assignment operators specified
Index: code/branches/pch/cmake/LibraryConfig.cmake
===================================================================
--- code/branches/pch/cmake/LibraryConfig.cmake	(revision 3166)
+++ code/branches/pch/cmake/LibraryConfig.cmake	(revision 3167)
@@ -67,26 +67,6 @@
     INCLUDE(PackageConfigMinGW)
     INCLUDE(PackageConfigMSVC)
-
-    # On Windows, DLLs have to be in the executable folder, install them
-    IF(DEP_BINARY_DIR AND WIN32)
-      # When installing a debug version, we really can't know which libraries
-      # are used in released mode because there might be deps of deps.
-      INSTALL(
-        DIRECTORY ${DEP_BINARY_DIR}/
-        DESTINATION bin
-        CONFIGURATIONS Debug
-        REGEX "^.*\\.pdb$" EXCLUDE
-      )
-
-      # Try to filter out all the debug libraries. If the regex doesn't do the
-      # job anymore, simply adjust it.
-      INSTALL(
-        DIRECTORY ${DEP_BINARY_DIR}/
-        DESTINATION bin
-        CONFIGURATIONS Release RelWithDebInfo MinSizeRel
-        REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
-      )
-    ENDIF(DEP_BINARY_DIR AND WIN32)
-  ENDIF(NOT DEPENDENCY_PACKAGE_DIR)
+    INCLUDE(PackageConfig) # For both msvc and mingw
+  ENDIF()
 ENDIF(DEPENDENCY_PACKAGE_ENABLE)
 
Index: code/branches/pch/cmake/PackageConfig.cmake
===================================================================
--- code/branches/pch/cmake/PackageConfig.cmake	(revision 3167)
+++ code/branches/pch/cmake/PackageConfig.cmake	(revision 3167)
@@ -0,0 +1,70 @@
+# General package configuration. Merely sets the include paths.
+# Library files are treated separately.
+
+# Check package version info
+# MAJOR: Interface breaking change somewhere (library version changed, etc.)
+# MINOR: Bug fix or small conformant changes
+SET(DEPENDENCY_VERSION_REQUIRED 2)
+IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
+  SET(DEPENDENCY_VERSION 1.0)
+ELSE()
+  # Get version from file
+  FILE(READ ${DEPENDENCY_PACKAGE_DIR}/version.txt _file_content)
+  SET(_match)
+  STRING(REGEX MATCH "([0-9]+.[0-9]+)" _match ${_file_content})
+  IF(_match)
+    SET(DEPENDENCY_VERSION ${_match})
+  ELSE()
+    MESSAGE(FATAL_ERROR "The version.txt file in the dependency file has corrupt version information.")
+  ENDIF()
+ENDIF()
+
+INCLUDE(CompareVersionStrings)
+COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${DEPENDENCY_VERSION_REQUIRED} _result)
+IF(NOT _result EQUAL 0)
+  MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
+          "Required version: ${DEPENDENCY_VERSION_REQUIRED}\n"
+	  "You can get a new version from www.orxonox.net")
+ENDIF()
+
+MESSAGE(STATUS "Using library package for the dependencies.")
+
+# Include paths and other special treatments
+SET(ENV{ALUTDIR}               ${DEP_INCLUDE_DIR}/freealut-1.1.0)
+SET(ENV{BOOST_ROOT}            ${DEP_INCLUDE_DIR}/boost-1.37.0)
+SET(ENV{CEGUIDIR}              ${DEP_INCLUDE_DIR}/cegui-0.6.2)
+SET(ENV{DXSDK_DIR}             ${DEP_INCLUDE_DIR}/directx-2007.aug)
+SET(ENV{ENETDIR}               ${DEP_INCLUDE_DIR}/enet-1.2)
+SET(ENV{LUA_DIR}               ${DEP_INCLUDE_DIR}/lua-5.1.4)
+SET(ENV{OGGDIR}                ${DEP_INCLUDE_DIR}/libogg-1.1.3)
+SET(ENV{VORBISDIR}             ${DEP_INCLUDE_DIR}/libvorbis-1.2.0)
+SET(ENV{OGRE_HOME}             ${DEP_INCLUDE_DIR}/ogre-1.4.9)
+SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
+SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal-1.1)
+LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.2/include)
+LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib-1.2.3/include)
+
+### INSTALL ###
+# On Windows, DLLs have to be in the executable folder, install them
+IF(WIN32 AND DEP_BINARY_DIR)
+  ## DEBUG
+  # When installing a debug version, we really can't know which libraries
+  # are used in released mode because there might be deps of deps.
+  # --> Copy all of them, except the debug databases
+  INSTALL(
+    DIRECTORY ${DEP_BINARY_DIR}/
+    DESTINATION bin
+    CONFIGURATIONS Debug
+    REGEX "^.*\\.pdb$" EXCLUDE
+  )
+
+  ## RELEASE
+  # Try to filter out all the debug libraries. If the regex doesn't do the
+  # job anymore, simply adjust it.
+  INSTALL(
+    DIRECTORY ${DEP_BINARY_DIR}/
+    DESTINATION bin
+    CONFIGURATIONS Release RelWithDebInfo MinSizeRel
+    REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE
+  )
+ENDIF()
Index: code/branches/pch/cmake/PackageConfigMSVC.cmake
===================================================================
--- code/branches/pch/cmake/PackageConfigMSVC.cmake	(revision 3166)
+++ code/branches/pch/cmake/PackageConfigMSVC.cmake	(revision 3167)
@@ -28,11 +28,4 @@
 IF(MSVC)
 
-  # MAJOR: Interface breaking change somewhere or added a new library
-  # MINOR: Updated a library to a new version
-  # PATCH: Bug fix or smaller things
-  SET(DEPENDENCY_VERSION 0.0.1)
-
-  MESSAGE(STATUS "Using library package for the dependencies.")
-
   # 64 bit system?
   IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -45,7 +38,4 @@
   STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?) .*$" "\\1"
          _msvc_version "${CMAKE_GENERATOR}")
-  IF(MSVC71)
-    SET(_msvc_version "7.1")
-  ENDIF(MSVC71)
 
   SET(DEP_INCLUDE_DIR ${DEPENDENCY_PACKAGE_DIR}/include)
@@ -62,20 +52,14 @@
   SET(CMAKE_LIBRARY_PATH ${DEP_LIBRARY_DIR})
 
-  # Include paths and other special treatments
-  SET(ENV{ALUTDIR}               ${DEP_INCLUDE_DIR}/freealut-1.1.0)
-  SET(ENV{BOOST_ROOT}            ${DEP_INCLUDE_DIR}/boost-1.37.0)
-  SET(ENV{CEGUIDIR}              ${DEP_INCLUDE_DIR}/cegui-0.6.2)
-  SET(ENV{DXSDK_DIR}             ${DEP_INCLUDE_DIR}/directx-2007.aug)
-  SET(ENV{ENETDIR}               ${DEP_INCLUDE_DIR}/enet-1.2)
-  SET(ENV{LUA_DIR}               ${DEP_INCLUDE_DIR}/lua-5.1.4)
-  SET(ENV{OGGDIR}                ${DEP_INCLUDE_DIR}/libogg-1.1.3)
-  SET(ENV{VORBISDIR}             ${DEP_INCLUDE_DIR}/libvorbis-1.2.0)
-  SET(ENV{OGRE_HOME}             ${DEP_INCLUDE_DIR}/ogre-1.4.9)
-  SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
-  SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal-1.1)
-  LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.2/include)
-  SET(TCL_LIBRARY                ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
-  LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib-1.2.3/include)
-  SET(ZLIB_LIBRARY               ${DEP_LIBRARY_DIR}/zdll.lib CACHE FILEPATH "")
+  # Certain find scripts don't behave as ecpected to we have
+  # to specify the libraries ourselves.
+  SET(TCL_LIBRARY  ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
+  SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib  CACHE FILEPATH "")
+
+  # Visual Leak Detector
+  SET(VLD_INCLUDE_DIR  ${DEP_INCLUDE_DIR}/vld-1.9h CACHE PATH "")
+  SET(VLD_LIBRARY_DIR  ${DEP_LIBRARY_DIR}          CACHE PATH "")
+  LINK_DIRECTORIES(${VLD_LIBRARY_DIR}) # Used for auto-linking
+  MARK_AS_ADVANCED(VLD_INCLUDE_DIR VLD_LIBRARY_DIR)
 
 ENDIF(MSVC)
Index: code/branches/pch/cmake/PackageConfigMinGW.cmake
===================================================================
--- code/branches/pch/cmake/PackageConfigMinGW.cmake	(revision 3166)
+++ code/branches/pch/cmake/PackageConfigMinGW.cmake	(revision 3167)
@@ -28,11 +28,4 @@
 IF(MINGW)
 
-  # MAJOR: Interface breaking change somewhere or added a new library
-  # MINOR: Updated a library to a new version
-  # PATCH: Bug fix or smaller things
-  SET(DEPENDENCY_VERSION 0.0.1)
-
-  MESSAGE(STATUS "Using library package for the dependencies.")
-
   # 64 bit system?
   IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -52,20 +45,8 @@
   SET(CMAKE_LIBRARY_PATH ${DEP_LIBRARY_DIR} ${DEP_BINARY_DIR})
 
-  # Include paths and other special treatments
-  SET(ENV{ALUTDIR}               ${DEP_INCLUDE_DIR}/freealut-1.1.0)
-  SET(ENV{BOOST_ROOT}            ${DEP_INCLUDE_DIR}/boost-1.37.0)
-  SET(ENV{CEGUIDIR}              ${DEP_INCLUDE_DIR}/cegui-0.6.2)
-  SET(ENV{DXSDK_DIR}             ${DEP_INCLUDE_DIR}/directx-2007.aug)
-  SET(ENV{ENETDIR}               ${DEP_INCLUDE_DIR}/enet-1.2)
-  SET(ENV{LUA_DIR}               ${DEP_INCLUDE_DIR}/lua-5.1.4)
-  SET(ENV{OGGDIR}                ${DEP_INCLUDE_DIR}/libogg-1.1.3)
-  SET(ENV{VORBISDIR}             ${DEP_INCLUDE_DIR}/libvorbis-1.2.0)
-  SET(ENV{OGRE_HOME}             ${DEP_INCLUDE_DIR}/ogre-1.4.9)
-  SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
-  SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal-1.1)
-  LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.2/include)
-  SET(TCL_LIBRARY                ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")
-  LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib-1.2.3/include)
-  SET(ZLIB_LIBRARY               ${DEP_BINARY_DIR}/zlib1.dll CACHE FILEPATH "")
+  # Certain find scripts don't behave as ecpected to we have
+  # to specify the libraries ourselves.
+  SET(TCL_LIBRARY  ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")
+  SET(ZLIB_LIBRARY ${DEP_BINARY_DIR}/zlib1.dll CACHE FILEPATH "")
 
 ENDIF(MINGW)
Index: code/branches/pch/cmake/PrecompiledHeaderFiles.cmake
===================================================================
--- code/branches/pch/cmake/PrecompiledHeaderFiles.cmake	(revision 3166)
+++ code/branches/pch/cmake/PrecompiledHeaderFiles.cmake	(revision 3167)
@@ -110,5 +110,8 @@
     GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
     # Make sure we recompile the pch file even if only the flags change
-    FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
+    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_PCH_GCC_FLAGS}")
+      SET(_INTERNAL_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
+      FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
+    ENDIF()
 
     # Set Compile flags for the other source files
@@ -157,5 +160,2 @@
     ENDIF(CMAKE_COMPILER_IS_GNU)
 ENDFUNCTION(PRECOMPILED_HEADER_FILES_POST_TARGET)
-
-# TODO: Investigate what happens when we suddenly disable PCH for a library
-# TODO: C and CXX
Index: code/branches/pch/cmake/TargetUtilities.cmake
===================================================================
--- code/branches/pch/cmake/TargetUtilities.cmake	(revision 3166)
+++ code/branches/pch/cmake/TargetUtilities.cmake	(revision 3167)
@@ -164,5 +164,5 @@
   IF(_arg_VERSION)
     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${_arg_VERSION})
-  ELSEIF(NOT ORXONOX_EXTERNAL)
+  ELSEIF(NOT _arg_ORXONOX_EXTERNAL)
     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${ORXONOX_VERSION})
   ENDIF()
Index: code/branches/pch/src/CMakeLists.txt
===================================================================
--- code/branches/pch/src/CMakeLists.txt	(revision 3166)
+++ code/branches/pch/src/CMakeLists.txt	(revision 3167)
@@ -29,5 +29,5 @@
 ADD_COMPILER_FLAGS("-DOIS_DYNAMIC_LIB")
 # Tolua binding speedup if required
-ADD_COMPILER_FLAGS("-DTOLUA_RELEASE" Release MinSizeRel TOLUA_PARSER_RELEASE)
+ADD_COMPILER_FLAGS("-DTOLUA_RELEASE" ORXONOX_RELEASE)
 
 # Default linking is SHARED
@@ -77,5 +77,5 @@
 
 SET(GENERATED_FILE_COMMENT
-   "DO NOT EDIT THIS FILE!
+   "DO NOT EDIT THIS FILE! <br>
     It has been automatically generated by CMake from OrxonoxConfig.h.in")
 # Copy and configure OrxonoxConfig which gets included in every file
@@ -108,4 +108,5 @@
   ${DIRECTX_INCLUDE_DIR}
   ${ZLIB_INCLUDE_DIR}
+  ${VLD_INCLUDE_DIR}
 
   # All library includes are prefixed with the path to avoid conflicts
@@ -152,6 +153,2 @@
 ADD_SUBDIRECTORY(network)
 ADD_SUBDIRECTORY(orxonox)
-
-# Apply version info
-SET_TARGET_PROPERTIES(util core network orxonox
-  PROPERTIES VERSION ${ORXONOX_VERSION})
Index: code/branches/pch/src/OrxonoxConfig.h.in
===================================================================
--- code/branches/pch/src/OrxonoxConfig.h.in	(revision 3166)
+++ code/branches/pch/src/OrxonoxConfig.h.in	(revision 3167)
@@ -34,10 +34,10 @@
 
 /**
- @file
- @brief
+@file
+@brief
     Various constants for compiler, architecture and platform.
-
+@remarks
     @GENERATED_FILE_COMMENT@
- */
+*/
 
 #ifndef _OrxonoxConfig_H__
@@ -52,5 +52,5 @@
 #cmakedefine ORXONOX_PLATFORM_UNIX /* Apple and Linux */
 
-/* Determine compiler and set ORXONOX_COMP_VER */
+// Determine compiler and set ORXONOX_COMP_VER
 #if defined( _MSC_VER )
 #  define ORXONOX_COMPILER_MSVC
@@ -75,13 +75,13 @@
 #endif
 
-/* Endianness */
+// Endianness
 #cmakedefine ORXONOX_BIG_ENDIAN
 #cmakedefine ORXONOX_LITTLE_ENDIAN
 
-/* Architecture */
+// Architecture
 #cmakedefine ORXONOX_ARCH_32
 #cmakedefine ORXONOX_ARCH_64
 
-/* See if we can use __forceinline or if we need to use __inline instead */
+// See if we can use __forceinline or if we need to use __inline instead
 #cmakedefine HAVE_FORCEINLINE
 #ifndef FORCEINLINE
@@ -93,5 +93,5 @@
 #endif
 
-/* Try to define function information */
+// Try to define function information
 #ifndef __FUNCTIONNAME__
 #  ifdef ORXONOX_COMPILER_BORLAND
@@ -115,5 +115,7 @@
 #define ORXONOX_VERSION_NAME "@ORXONOX_VERSION_NAME@"
 
-#define ORXONOX_VERSION ((ORXONOX_VERSION_MAJOR << 16) | (ORXONOX_VERSION_MINOR << 8) | ORXONOX_VERSION_PATCH)
+//! Defines version info encoded as 0xMMIIPP (M: Major version, I: Minor version, P: Patch version, all as hex)
+#define ORXONOX_VERSION \
+    ((ORXONOX_VERSION_MAJOR << 16) | (ORXONOX_VERSION_MINOR << 8) | ORXONOX_VERSION_PATCH)
 
 
@@ -123,10 +125,9 @@
 #ifdef ORXONOX_PLATFORM_UNIX
 
-/* TODO: Check what this actually is and whether we need it or not */
+// TODO: Check what this actually is and whether we need it or not
 #if 0
 #  ifdef ORXONOX_PLATFORM_APPLE
 #    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"
-#  else
-/* ORXONOX_PLATFORM_LINUX */
+#  else // ORXONOX_PLATFORM_LINUX
 #    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
 #  endif
@@ -151,8 +152,18 @@
 
 /*---------------------------------
- * Includes
- *-------------------------------*/
-/* Define the english written operators like and, or, xor
- * This is C++ standard, but the Microsoft compiler doesn't define them. */
+ * Options
+ *-------------------------------*/
+/**
+@def ORXONOX_RELEASE
+    Enables expensive (build time) optimisations and disables certain features
+*/
+#cmakedefine ORXONOX_RELEASE
+
+
+/*---------------------------------
+ * Includes and Declarations
+ *-------------------------------*/
+// Define the english written operators like and, or, xor
+// This is C++ standard, but the Microsoft compiler doesn't define them.
 #cmakedefine HAVE_ISO646_H
 #ifdef HAVE_ISO646_H
@@ -181,5 +192,11 @@
 */
 
-/* Forward declare the everywhere used std::string */
+// Always include the memory leak detector for MSVC except for actual releases
+// Note: Although officially supported, VLD does not work with MSVC 9
+#if defined(ORXONOX_COMPILER_MSVC) && _MSC_VER < 1500 && !defined(ORXONOX_RELEASE)
+#  include <vld.h>
+#endif
+
+// Forward declare the everywhere used std::string
 namespace std
 {
@@ -190,14 +207,3 @@
 }
 
-/* Just in case you don't include a standard header */
-#ifndef NULL
-  #define NULL 0
-#endif
-
-/* Visual Leak Detector looks for memory leaks */
-#cmakedefine VISUAL_LEAK_DETECTOR_ENABLE
-#ifdef VISUAL_LEAK_DETECTOR_ENABLE
-#  include <vld.h>
-#endif
-
 #endif /* _OrxonoxConfig_H__ */
Index: code/branches/pch/src/SpecialConfig.h.in
===================================================================
--- code/branches/pch/src/SpecialConfig.h.in	(revision 3166)
+++ code/branches/pch/src/SpecialConfig.h.in	(revision 3167)
@@ -28,12 +28,12 @@
 
 /**
- @file
- @brief
+@file
+@brief
     Various constants and options that only affect very little code.
- @note
+@note
     This is merely to avoid recompiling everything when only a path changes.
-
+@remarks
     @GENERATED_FILE_COMMENT@
- */
+*/
 
 #ifndef _SpecialConfig_H__
@@ -42,53 +42,73 @@
 #include "OrxonoxConfig.h"
 
-/* Set whether we must suffix "ceguilua/" for the CEGUILua.h include */
+/**
+@def CEGUILUA_USE_INTERNAL_LIBRARY
+    Set whether we must suffix "ceguilua/" for the CEGUILua.h include
+*/
 #cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY
 
-/* Defined if a precompiled depdency package was used. We then copy all libraries
-   too when installing. */
+/**
+@def DEPENDENCY_PACKAGE_ENABLE
+    Defined if a precompiled depdency package was used. We then copy all libraries
+    too when installing.
+*/
 #cmakedefine DEPENDENCY_PACKAGE_ENABLE
 
-/* Orxonox either gets installed to the system or just into a folder.
-   The latter uses relative paths. */
+/**
+@def INSTALL_COPYABLE
+    Orxonox either gets installed to the system or just into a folder.
+    The latter uses relative paths.
+*/
 #cmakedefine INSTALL_COPYABLE
 
-/* Using MSVC or XCode IDE */
+/**
+@def CMAKE_CONFIGURATION_TYPES
+    Using MSVC or XCode IDE
+*/
 #cmakedefine CMAKE_CONFIGURATION_TYPES
 
-/* Handle default ConfigValues */
+// Handle default ConfigValues
 namespace orxonox
 {
-    const char* const ORXONOX_RUNTIME_INSTALL_PATH("@ORXONOX_RUNTIME_INSTALL_PATH@");
-    const char* const ORXONOX_MEDIA_INSTALL_PATH  ("@ORXONOX_MEDIA_INSTALL_PATH@");
+    // INSTALLATION PATHS
+    const char ORXONOX_RUNTIME_INSTALL_PATH[] = "@ORXONOX_RUNTIME_INSTALL_PATH@";
+    const char ORXONOX_MEDIA_INSTALL_PATH[]   = "@ORXONOX_MEDIA_INSTALL_PATH@";
     /* Config and Log path might be relative because they could be user and therefore runtime dependent */
-    const char* const ORXONOX_CONFIG_INSTALL_PATH ("@ORXONOX_CONFIG_INSTALL_PATH@");
-    const char* const ORXONOX_LOG_INSTALL_PATH    ("@ORXONOX_LOG_INSTALL_PATH@");
+    const char ORXONOX_CONFIG_INSTALL_PATH[]  = "@ORXONOX_CONFIG_INSTALL_PATH@";
+    const char ORXONOX_LOG_INSTALL_PATH[]     = "@ORXONOX_LOG_INSTALL_PATH@";
 
-    const char* const ORXONOX_MEDIA_DEV_PATH      ("@CMAKE_MEDIA_OUTPUT_DIRECTORY@");
+    // DEVELOPMENT RUN PATHS
+    const char ORXONOX_MEDIA_DEV_PATH[]       = "@CMAKE_MEDIA_OUTPUT_DIRECTORY@";
 #ifdef CMAKE_CONFIGURATION_TYPES
-    const char* const ORXONOX_CONFIG_DEV_PATH     ("@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE));
-    const char* const ORXONOX_LOG_DEV_PATH        ("@CMAKE_LOG_OUTPUT_DIRECTORY@/"    MACRO_QUOTEME(CMAKE_BUILD_TYPE));
+    const char ORXONOX_CONFIG_DEV_PATH[]      = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE);
+    const char ORXONOX_LOG_DEV_PATH[]         = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    MACRO_QUOTEME(CMAKE_BUILD_TYPE);
 #else
-    const char* const ORXONOX_CONFIG_DEV_PATH     ("@CMAKE_CONFIG_OUTPUT_DIRECTORY@");
-    const char* const ORXONOX_LOG_DEV_PATH        ("@CMAKE_LOG_OUTPUT_DIRECTORY@");
+    const char ORXONOX_CONFIG_DEV_PATH[]      = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
+    const char ORXONOX_LOG_DEV_PATH[]         = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
 #endif
     
     /* OGRE Plugins */
 #ifdef NDEBUG
-    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_RELEASE@");
+    const char ORXONOX_OGRE_PLUGINS[] = "@OGRE_PLUGINS_RELEASE@";
 #  ifdef DEPENDENCY_PACKAGE_ENABLE
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
+    const char ORXONOX_OGRE_PLUGINS_FOLDER[] = ".";
 #  else
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_RELEASE@");
+    const char ORXONOX_OGRE_PLUGINS_FOLDER[] = "@OGRE_PLUGINS_FOLDER_RELEASE@";
 #  endif
 #else
-    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_DEBUG@");
+    const char ORXONOX_OGRE_PLUGINS[] = "@OGRE_PLUGINS_DEBUG@";
 #  ifdef DEPENDENCY_PACKAGE_ENABLE
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
+    const char ORXONOX_OGRE_PLUGINS_FOLDER[] = ".";
 #  else
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_DEBUG@");
+    const char ORXONOX_OGRE_PLUGINS_FOLDER[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";
 #  endif
 #endif
 }
 
+/**
+@def ORXONOX_USE_WINMAIN
+    Use main() or WinMain()?
+*/
+#cmakedefine ORXONOX_USE_WINMAIN
+
 #endif /* _SpecialConfig_H__ */
Index: code/branches/pch/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/pch/src/orxonox/CMakeLists.txt	(revision 3166)
+++ code/branches/pch/src/orxonox/CMakeLists.txt	(revision 3167)
@@ -33,4 +33,9 @@
 ADD_SUBDIRECTORY(tools)
 
+# Translate argument
+IF(ORXONOX_USE_WINMAIN)
+  SET(ORXONOX_WIN32 WIN32)
+ENDIF()
+
 ORXONOX_ADD_EXECUTABLE(orxonox
   FIND_HEADER_FILES
@@ -44,4 +49,6 @@
     OrxonoxPrecompiledHeaders.h
   PCH_NO_DEFAULT
+  # When defined as WIN32 this removes the console window on Windows
+  ${ORXONOX_WIN32}
   LINK_LIBRARIES
     ${OGRE_LIBRARY}
@@ -85,4 +92,4 @@
   STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?) .*$" "\\1"
          VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}")
-  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox.vcproj.user" "${CMAKE_CURRENT_BINARY_DIR}/orxonox.vcproj.user")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox.vcproj.user")
 ENDIF(MSVC)
Index: code/branches/pch/src/orxonox/Main.cc
===================================================================
--- code/branches/pch/src/orxonox/Main.cc	(revision 3166)
+++ code/branches/pch/src/orxonox/Main.cc	(revision 3167)
@@ -28,12 +28,9 @@
  */
  
- /**
- @mainpage Orxonox Documentation
- */
-
- /**
- @file
- @brief Entry point of the program.
-  */
+/**
+@file
+@brief
+    Entry point of the program.
+*/
 
 #include "OrxonoxConfig.h"
@@ -47,5 +44,9 @@
     Main method. Game starts here (except for static initialisations).
 */
+#ifdef ORXONOX_USE_WINMAIN
+INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
+#else
 int main(int argc, char** argv)
+#endif
 {
     {
Index: code/branches/pch/src/orxonox/orxonox.vcproj.user
===================================================================
--- code/branches/pch/src/orxonox/orxonox.vcproj.user	(revision 3166)
+++ 	(revision )
@@ -1,45 +1,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
-	ProjectType="Visual C++"
-	Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
-	ShowAllFiles="false"
-	>
-	<Configurations>
-		<Configuration
-			Name="Debug|${MSVC_PLATFORM}"
-			>
-			<DebugSettings
-				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
-				EnvironmentMerge="true"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|${MSVC_PLATFORM}"
-			>
-			<DebugSettings
-				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
-				EnvironmentMerge="true"
-			/>
-		</Configuration>
-		<Configuration
-			Name="MinSizeRel|${MSVC_PLATFORM}"
-			>
-			<DebugSettings
-				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
-				EnvironmentMerge="true"
-			/>
-		</Configuration>
-		<Configuration
-			Name="RelWithDebInfo|${MSVC_PLATFORM}"
-			>
-			<DebugSettings
-				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
-				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
-				EnvironmentMerge="true"
-			/>
-		</Configuration>
-	</Configurations>
-</VisualStudioUserFile>
Index: code/branches/pch/src/orxonox/orxonox.vcproj.user.in
===================================================================
--- code/branches/pch/src/orxonox/orxonox.vcproj.user.in	(revision 3167)
+++ code/branches/pch/src/orxonox/orxonox.vcproj.user.in	(revision 3167)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="MinSizeRel|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="RelWithDebInfo|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>
Index: code/branches/pch/src/orxonox/sound/SoundBase.h
===================================================================
--- code/branches/pch/src/orxonox/sound/SoundBase.h	(revision 3166)
+++ code/branches/pch/src/orxonox/sound/SoundBase.h	(revision 3167)
@@ -30,4 +30,5 @@
 
 #include "OrxonoxPrereqs.h"
+#include <cstring> // define NULL
 
 namespace orxonox
Index: code/branches/pch/src/tolua/CMakeLists.txt
===================================================================
--- code/branches/pch/src/tolua/CMakeLists.txt	(revision 3166)
+++ code/branches/pch/src/tolua/CMakeLists.txt	(revision 3167)
@@ -61,6 +61,4 @@
 )
 
-OPTION(TOLUA_PARSER_RELEASE "Disable all debug messages from tolua bind files for Release and MinSizeRel build types." FALSE)
-
 # Set some variables to the cache in order to use them in the TOLUA macro
 SET(TOLUA_PARSER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/all-${LUA_VERSION}.lua" CACHE INTERNAL "")
