partial merge of the webgl branch
authorkoda
Tue, 21 Jan 2014 22:38:13 +0100
changeset 10015 4feced261c68
parent 10014 56d2f2d5aad8 (diff)
parent 9984 84835d0ceb64 (current diff)
child 10017 de822cd3df3a
partial merge of the webgl branch This commit contains the new pas2c conversion tool, the pascal to c build structure and the opengl2 rendering backend. Patch reviewed by unC0Rr.
CMakeLists.txt
QTfrontend/CMakeLists.txt
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/net/newnetclient.cpp
QTfrontend/net/newnetclient.h
QTfrontend/ui/dialog/input_password.cpp
QTfrontend/ui/page/pagemain.cpp
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/widget/about.cpp
cmake_modules/FindGLEW.cmake
gameServer/Actions.hs
gameServer/CMakeLists.txt
gameServer/HWProtoInRoomState.hs
gameServer/hedgewars-server.cabal
hedgewars/ArgParsers.pas
hedgewars/CMakeLists.txt
hedgewars/LuaPas.pas
hedgewars/SDLh.pas
hedgewars/adler32.pas
hedgewars/config.inc.in
hedgewars/hwengine.ico
hedgewars/hwengine.pas
hedgewars/hwengine.rc
hedgewars/options.inc
hedgewars/pas2cRedo.pas
hedgewars/pas2cSystem.pas
hedgewars/res/hwengine.rc
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
hedgewars/uAmmos.pas
hedgewars/uCaptions.pas
hedgewars/uChat.pas
hedgewars/uCollisions.pas
hedgewars/uCommandHandlers.pas
hedgewars/uConsole.pas
hedgewars/uConsts.pas
hedgewars/uCursor.pas
hedgewars/uFloat.pas
hedgewars/uGame.pas
hedgewars/uGears.pas
hedgewars/uGearsHandlers.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
hedgewars/uIO.pas
hedgewars/uInputHandler.pas
hedgewars/uLand.pas
hedgewars/uLandGenMaze.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uLandPainted.pas
hedgewars/uLandTemplates.pas
hedgewars/uLandTexture.pas
hedgewars/uLocale.pas
hedgewars/uMatrix.pas
hedgewars/uMisc.pas
hedgewars/uPhysFSLayer.pas
hedgewars/uRandom.pas
hedgewars/uRender.pas
hedgewars/uRenderUtils.pas
hedgewars/uScript.pas
hedgewars/uSound.pas
hedgewars/uStats.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uTypes.pas
hedgewars/uUtils.pas
hedgewars/uVariables.pas
hedgewars/uVisualGears.pas
hedgewars/uVisualGearsHandlers.pas
hedgewars/uVisualGearsList.pas
hedgewars/uWeb.pas
hedgewars/uWorld.pas
hedgewars/videorec/avwrapper.c
misc/liblua/CMakeLists.txt
misc/liblua/lauxlib.c
misc/libphyslayer/CMakeLists.txt
misc/libphyslayer/hwpacksmounter.h
project_files/Android-build/CMakeLists.txt
project_files/frontlib/hwconsts.h
project_files/frontlib/md5/md5.h
project_files/frontlib/model/gamesetup.h
project_files/frontlib/model/map.h
project_files/frontlib/model/mapcfg.h
project_files/frontlib/model/room.h
project_files/frontlib/model/team.h
project_files/frontlib/net/netconn.h
project_files/frontlib/net/netconn_internal.h
project_files/hwc/rtl/SysUtils.h
project_files/hwc/rtl/Types.h
project_files/hwc/rtl/fpcrtl.h
project_files/hwc/rtl/misc.c
project_files/hwc/rtl/misc.h
project_files/hwc/rtl/sysutils.c
project_files/hwc/rtl/tests/check_check.c
project_files/hwc/rtl/tests/check_fileio.c
project_files/hwc/rtl/tests/check_misc.c
project_files/hwc/rtl/tests/check_system.c
project_files/hwc/rtl/tests/check_sysutils.c
project_files/hwc/rtl/tests/fileio_test.c
project_files/hwc/rtl/tests/main.c
share/CMakeLists.txt
share/hedgewars/Data/Shaders/CMakeLists.txt
tools/pas2c/Main.hs
tools/pas2c/Pas2C.hs
tools/pas2c/PascalBasics.hs
tools/pas2c/PascalPreprocessor.hs
tools/pas2c/PascalUnitSyntaxTree.hs
--- a/.travis.yml	Thu Jan 09 19:10:12 2014 +0100
+++ b/.travis.yml	Tue Jan 21 22:38:13 2014 +0100
@@ -11,16 +11,17 @@
   # Debug build
   - BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug"
   # Everything that's optional
-  - BUILD_ARGS="-NOPNG=1"
-  - BUILD_ARGS="-NOVIDEOREC=1"
-  - BUILD_ARGS="-NOSERVER=1"
-  - BUILD_ARGS="-LUA_SYSTEM=0"
+  - BUILD_ARGS="-DNOPNG=1"
+  - BUILD_ARGS="-DNOVIDEOREC=1"
+  - BUILD_ARGS="-DNOSERVER=1"
+  - BUILD_ARGS="-DLUA_SYSTEM=0"
+  - BUILD_ARGS="-DPHYSFS_SYSTEM=0"
 matrix:
   allow_failures:
     # Failures we expect here
 before_install:
   - sudo apt-get update -qq
-  - sudo apt-get install debhelper cmake dpkg-dev libqt4-dev fp-compiler libsdl1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev libsdl-image1.2-dev libsdl-net1.2-dev bzip2 fp-units-gfx ghc libghc-stm-dev libghc-network-dev libghc-dataenc-dev libghc-hslogger-dev libghc-utf8-string-dev liblua5.1-0-dev imagemagick libghc-bytestring-show-dev fpc libpng-dev libavcodec-dev libavformat-dev freeglut3-dev libghc-mtl-dev libghc-parsec3-dev libghc-vector-dev qt4-qmake fp-units-misc libghc-random-dev
+  - sudo apt-get install debhelper cmake dpkg-dev libqt4-dev libphysfs-dev fp-compiler libsdl1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev libsdl-image1.2-dev libsdl-net1.2-dev bzip2 fp-units-gfx ghc libghc-stm-dev libghc-network-dev libghc-dataenc-dev libghc-hslogger-dev libghc-utf8-string-dev liblua5.1-0-dev imagemagick libghc-bytestring-show-dev fpc libpng-dev libavcodec-dev libavformat-dev freeglut3-dev libghc-mtl-dev libghc-parsec3-dev libghc-vector-dev qt4-qmake fp-units-misc libghc-random-dev
 script: 
   - mkdir build && cd build && cmake $BUILD_ARGS .. && make VERBOSE=1
 notifications:
--- a/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -18,12 +18,12 @@
 
 #libraries are built shared unless explicitly added as a static
 option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON)
-#set this to ON when 2.1.0 becomes more widespread (and only for linux)
-option(PHYSFS_SYSTEM "Use system physfs (off)" OFF)
 
 if(WIN32 OR APPLE)
+    option(PHYSFS_SYSTEM "Use system physfs (off)" OFF)
     option(LUA_SYSTEM "Use system lua (off)" OFF)
 else()
+    option(PHYSFS_SYSTEM "Use system physfs (on)" ON)
     option(LUA_SYSTEM "Use system lua (on)" ON)
 endif()
 
@@ -33,8 +33,7 @@
 option(MINIMAL_FLAGS "Respect system flags as much as possible (off)" OFF)
 option(NOAUTOUPDATE "Disable OS X Sparkle update checking (off)" OFF)
 
-option(WEBGL "Enable WebGL build (implies BUILD_ENGINE_C) [default: off]" OFF)
-option(BUILD_ENGINE_C "Compile hwengine as native C [default: off]" ${WEBGL})
+option(BUILD_ENGINE_C "Compile hwengine as native C [default: off]" OFF)
 option(GL2 "Enable OpenGL 2 rendering [default: off]" OFF)
 
 set(GHFLAGS "" CACHE STRING "Additional Haskell flags")
@@ -42,11 +41,15 @@
     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
 endif()
 
+#system paths for finding required fonts (see share/hedgewars/Data/fonts)
+#subdirectories will NOT be searched.
+#all fonts that can't be found will be bundled with hedgewars
+set(FONTS_DIRS "" CACHE STRING "Additional paths to folders where required fonts can be found ( ; is separator)")
 
 #versioning
 set(CPACK_PACKAGE_VERSION_MAJOR 0)
 set(CPACK_PACKAGE_VERSION_MINOR 9)
-set(CPACK_PACKAGE_VERSION_PATCH 20)
+set(CPACK_PACKAGE_VERSION_PATCH 21)
 set(HEDGEWARS_PROTO_VER 48)
 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 include(${CMAKE_MODULE_PATH}/revinfo.cmake)
@@ -62,15 +65,16 @@
 
 
 #when build type is not specified, assume Debug/Release according to build version information
-if (CMAKE_BUILD_TYPE)
-    string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
-    if ( NOT( (CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "DEBUG") ) )
-        set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
-        message (STATUS "Unknown build type, using default (${default_build_type})")
-    endif ()
-else (CMAKE_BUILD_TYPE)
-    set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
-endif (CMAKE_BUILD_TYPE)
+if(CMAKE_BUILD_TYPE)
+    string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
+    if(NOT((CMAKE_BUILD_TYPE MATCHES "RELEASE") OR
+           (CMAKE_BUILD_TYPE MATCHES "DEBUG")))
+        set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
+        message(STATUS "Unknown build type, using default (${default_build_type})")
+    endif()
+else(CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
+endif(CMAKE_BUILD_TYPE)
 
 
 #perform safe check that enable/disable compilation features
@@ -85,7 +89,7 @@
 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0")
 
 #CMake adds a lot of additional configuration flags, so let's clear them up
-if(${MINIMAL_FLAGS})
+if(MINIMAL_FLAGS)
     unset(CMAKE_C_FLAGS_RELEASE)
     unset(CMAKE_C_FLAGS_DEBUG)
     unset(CMAKE_CXX_FLAGS_RELEASE)
@@ -122,7 +126,7 @@
 if(BUILD_ENGINE_C)
     find_package(Clang REQUIRED)
 
-    if(CLANG_VERSION VERSION_LESS "3.0")
+    if(${CLANG_VERSION} VERSION_LESS "3.0")
         message(FATAL_ERROR "LLVM/Clang compiler required version is 3.0 but version ${CLANG_VERSION} was found!")
     endif()
 
@@ -138,13 +142,12 @@
 
 
 #lua discovery
-if (${LUA_SYSTEM})
-    if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
+if(LUA_SYSTEM)
+    if(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
         find_package(Lua)
     endif()
 
-    if (LUA_LIBRARY AND LUA_INCLUDE_DIR)
-        set(LUA_FOUND TRUE)
+    if(LUA_LIBRARY AND LUA_INCLUDE_DIR)
         #use an IMPORTED tharget so that we can just use 'lua' to link
         add_library(lua UNKNOWN IMPORTED)
         set_target_properties(lua PROPERTIES IMPORTED_LOCATION ${LUA_LIBRARY})
@@ -152,7 +155,7 @@
         message(FATAL_ERROR "Missing Lua! Rerun cmake with -DLUA_SYSTEM=off to build the internal version")
     endif()
 else()
-    if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
+    if(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
         message(STATUS "LUA will be provided by the bundled sources")
     endif()
     set(lua_output_name "hwlua")
@@ -161,8 +164,8 @@
 
 
 #physfs discovery
-if (${PHYSFS_SYSTEM})
-    if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
+if(PHYSFS_SYSTEM)
+    if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
         find_package(PhysFS)
     endif()
 
@@ -176,37 +179,33 @@
         string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}")
         set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}")
 
-        if (physfs_detected_ver VERSION_LESS "2.1.0")
-            message(FATAL_ERROR "PhysFS version is too old (dected ${physfs_detected_ver}, required 2.1.0)")
-            set(physfs_too_old true)
+        if(${physfs_detected_ver} VERSION_LESS 2.0.0)
+            message(FATAL_ERROR "PhysFS version is too old (detected ${physfs_detected_ver}, required 2.0.0)\n"
+                                "Perform an update or rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
         endif()
     endif()
 
-    if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
-        message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
-    else()
+    if(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR)
         #use an IMPORTED tharget so that we can just use 'physfs' to link
         add_library(physfs UNKNOWN IMPORTED)
         set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY})
+    else()
+        message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
     endif()
 else()
-    if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
+    if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
         message(STATUS "PhysFS will be provided by the bundled sources")
     endif()
     set(physfs_output_name "hwphysfs")
     add_subdirectory(misc/libphysfs)
 endif()
 
-find_package_or_disable_msg(FFMPEG NOVIDEOREC "Video recording will not be built")
+find_package_or_disable_msg(LIBAV NOVIDEOREC "Video recording will not be built")
 
 #physfs helper library
 add_subdirectory(misc/libphyslayer)
 
-if(NOT BUILD_ENGINE_LIBRARY AND APPLE)
-    add_subdirectory(hedgewars/sdlmain)
-endif()
-
-#TODO: nowadays this could be merged inside hedgewars/CMakeLists.txt
+#maybe this could be merged inside hedgewars/CMakeLists.txt
 if(BUILD_ENGINE_C)
     #pascal to c converter
     add_subdirectory(tools/pas2c)
@@ -216,20 +215,23 @@
     add_subdirectory(hedgewars)
 endif()
 
-if(WEBGL)
-    #WEBGL deps
-else(WEBGL)
-    #Android related build scripts
-    #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
-    if(ANDROID)
-        add_subdirectory(project_files/Android-build)
-    else(ANDROID)
-        add_subdirectory(bin)
-        add_subdirectory(QTfrontend)
-        add_subdirectory(share)
-        add_subdirectory(tools)
-    endif(ANDROID)
-endif(WEBGL)
+#Android related build scripts
+#TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
+if(ANDROID)
+    add_subdirectory(project_files/Android-build)
+else(ANDROID)
+    add_subdirectory(bin)
+    add_subdirectory(QTfrontend)
+    add_subdirectory(share)
+    add_subdirectory(tools)
+endif(ANDROID)
 
 include(${CMAKE_MODULE_PATH}/cpackvars.cmake)
 
+enable_testing()
+
+set(LUATESTS "${CMAKE_SOURCE_DIR}/tests/lua")
+set(LUAAPITESTS "${LUATESTS}/luaAPI")
+set(TESTSDATADIR "${CMAKE_SOURCE_DIR}/share/hedgewars/Data")
+
+add_test("LuaAPI:GetZoom/SetZoom" "bin/hwengine" "--prefix" "${TESTSDATADIR}" "--lua-test" "${LUATESTS}/luaAPI/zoom_get_set.lua")
--- a/INSTALL	Thu Jan 09 19:10:12 2014 +0100
+++ b/INSTALL	Tue Jan 21 22:38:13 2014 +0100
@@ -8,7 +8,7 @@
  - SDL_image >= 1.2
  - SDL_ttf >= 2.0
  - Lua >= 5.1.0
- - Physfs >= 2.1.0
+ - Physfs >= 2.0.0
 For server:
  - Glasgow Haskell Compiler >= 6.10
  - bytestring-show package
--- a/QTfrontend/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -22,10 +22,10 @@
 find_package(SDL1or2)            #video in SDLInteraction
 find_package(SDL_mixer REQUIRED) #audio in SDLInteraction
 
-if(${FFMPEG_FOUND})
+if(LIBAV_FOUND)
     add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
-    include_directories(${FFMPEG_INCLUDE_DIR})
-    list(APPEND HW_LINK_LIBS ${FFMPEG_LIBRARIES})
+    include_directories(${LIBAV_INCLUDE_DIR})
+    list(APPEND HW_LINK_LIBS ${LIBAV_LIBRARIES})
 endif()
 
 # server messages localization
@@ -152,7 +152,7 @@
 
 set(hwfr_rez hedgewars.qrc)
 
-if(${BUILD_ENGINE_LIBRARY})
+if(BUILD_ENGINE_LIBRARY)
     add_definitions(-DHWLIBRARY=1)
     set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
     list(APPEND HW_LINK_LIBS ${hwlibname})
--- a/QTfrontend/achievements.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/achievements.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/achievements.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/achievements.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/binds.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/binds.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/binds.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/binds.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/campaign.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/campaign.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/campaign.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/campaign.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/drawmapscene.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/drawmapscene.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -459,7 +459,7 @@
         l.append(center);
     } else
     {
-        qreal angleDelta = qMax(0.1, qMin(0.7, 120 / r));
+        qreal angleDelta = qMax(static_cast<qreal> (0.1), qMin(static_cast<qreal> (0.7), 120 / r));
         for(qreal angle = 0.0; angle < 2*M_PI; angle += angleDelta)
             l.append(center + QPointF(rx * cos(angle), ry * sin(angle)));
         l.append(l.first());
--- a/QTfrontend/drawmapscene.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/drawmapscene.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/game.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/game.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/game.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/game.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/gameuiconfig.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/gameuiconfig.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/gameuiconfig.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/gameuiconfig.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/hwconsts.cpp.in	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/hwconsts.cpp.in	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/hwconsts.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/hwconsts.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/hwform.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/hwform.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/hwform.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/hwform.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/main.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/main.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/GameStyleModel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/GameStyleModel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/GameStyleModel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/GameStyleModel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/HatModel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/HatModel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/HatModel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/HatModel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/MapModel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/MapModel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/MapModel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/MapModel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/ThemeModel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/ThemeModel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/ThemeModel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/ThemeModel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/ammoSchemeModel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/ammoSchemeModel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/ammoSchemeModel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/ammoSchemeModel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/netserverslist.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/netserverslist.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/netserverslist.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/netserverslist.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/roomslistmodel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/roomslistmodel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/model/roomslistmodel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/model/roomslistmodel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/hwmap.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/hwmap.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Ulyanov Igor <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/hwmap.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/hwmap.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netregister.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netregister.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netregister.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netregister.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netserver.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netserver.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netserver.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netserver.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netudpserver.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netudpserver.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netudpserver.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netudpserver.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netudpwidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netudpwidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/netudpwidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/netudpwidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/newnetclient.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/newnetclient.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/newnetclient.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/newnetclient.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/proto.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/proto.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/proto.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/proto.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/recorder.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/recorder.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/recorder.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/recorder.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/tcpBase.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/tcpBase.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/net/tcpBase.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/net/tcpBase.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/sdlkeys.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/sdlkeys.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/team.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/team.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/team.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/team.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
--- a/QTfrontend/ui/dialog/ask_quit.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/ask_quit.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/ask_quit.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/ask_quit.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/input_ip.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/input_ip.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/input_ip.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/input_ip.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/input_password.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/input_password.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/input_password.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/input_password.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/upload_video.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/upload_video.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/dialog/upload_video.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/dialog/upload_video.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/AbstractPage.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/AbstractPage.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/AbstractPage.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/AbstractPage.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageadmin.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageadmin.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageadmin.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageadmin.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagecampaign.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagecampaign.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagecampaign.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagecampaign.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageconnecting.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageconnecting.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageconnecting.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageconnecting.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagedata.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagedata.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagedata.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagedata.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagedrawmap.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagedrawmap.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagedrawmap.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagedrawmap.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageeditteam.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageeditteam.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageeditteam.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagegamestats.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagegamestats.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagegamestats.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagegamestats.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageinfo.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageinfo.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageinfo.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageinfo.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageingame.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageingame.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageingame.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageingame.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagemain.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagemain.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagemain.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagemain.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagemultiplayer.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagemultiplayer.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagemultiplayer.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagemultiplayer.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenet.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenet.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenet.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenet.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenetgame.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenetgame.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenetgame.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenetgame.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenetserver.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenetserver.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagenetserver.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagenetserver.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageoptions.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageoptions.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageoptions.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageoptions.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageplayrecord.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageplayrecord.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageplayrecord.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageplayrecord.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageroomslist.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,6 +53,8 @@
 
 QLayout * PageRoomsList::bodyLayoutDefinition()
 {
+    // TODO move stylesheet stuff into css/qt.css
+
     QVBoxLayout * pageLayout = new QVBoxLayout();
     pageLayout->setSpacing(0);
 
@@ -60,10 +62,29 @@
     topLayout->setSpacing(0);
     pageLayout->addLayout(topLayout, 0);
 
+    // State button
+
+    QPushButton * btnState = new QPushButton(tr("Room state"));
+    btnState->setStyleSheet("QPushButton { background-color: #F6CB1C; border-color: #F6CB1C; color: #130F2A; padding: 1px 3px 3px 3px; margin: 0px; border-bottom: none; border-radius: 0px; border-top-left-radius: 10px; } QPushButton:hover { background-color: #FFEB3C; border-color: #F6CB1C; color: #000000 } QPushButton:pressed { background-color: #FFEB3C; border-color: #F6CB1C; color: #000000; }");
+    btnState->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+
+    // State menu
+
+    QMenu * stateMenu = new QMenu(btnState);
+    showGamesInLobby = new QAction(QAction::tr("Show games in lobby"), stateMenu);
+    showGamesInLobby->setCheckable(true);
+    showGamesInLobby->setChecked(true);
+    showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
+    showGamesInProgress->setCheckable(true);
+    showGamesInProgress->setChecked(true);
+    stateMenu->addAction(showGamesInLobby);
+    stateMenu->addAction(showGamesInProgress);
+    btnState->setMenu(stateMenu);
+
     // Help/prompt message at top
     QLabel * lblDesc = new QLabel(tr("Search for a room:"));
     lblDesc->setObjectName("lblDesc");
-    lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
+    lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; padding: 5px 10px 3px 6px;}");
     lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     lblDesc->setFixedHeight(24);
     lblDesc->setMinimumWidth(0);
@@ -97,16 +118,17 @@
     BtnJoin->setEnabled(false);
 
     // Add widgets to top layout
-    topLayout->addWidget(lblDesc, 1, 0);
-    topLayout->addWidget(searchContainer, 1, 1);
-    topLayout->addWidget(corner, 1, 2, Qt::AlignBottom);
-    topLayout->addWidget(BtnCreate, 0, 4, 2, 1);
-    topLayout->addWidget(BtnJoin, 0, 5, 2, 1);
+    topLayout->addWidget(btnState, 1, 0);
+    topLayout->addWidget(lblDesc, 1, 1);
+    topLayout->addWidget(searchContainer, 1, 2);
+    topLayout->addWidget(corner, 1, 3, Qt::AlignBottom);
+    topLayout->addWidget(BtnCreate, 0, 5, 2, 1);
+    topLayout->addWidget(BtnJoin, 0, 6, 2, 1);
 
     // Top layout stretch
     topLayout->setRowStretch(0, 1);
     topLayout->setRowStretch(1, 0);
-    topLayout->setColumnStretch(3, 1);
+    topLayout->setColumnStretch(4, 1);
 
     // Rooms list and chat with splitter
     m_splitter = new QSplitter();
@@ -132,43 +154,6 @@
     roomsList->setFocusPolicy(Qt::NoFocus);
     roomsLayout->addWidget(roomsList, 200);
 
-    // Room filters container
-
-    QWidget * filtersContainer = new QWidget();
-    filtersContainer->setMaximumWidth(800);
-    filtersContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
-    roomsLayout->addSpacing(7);
-    roomsLayout->addWidget(filtersContainer, 0, Qt::AlignHCenter);
-    roomsLayout->addSpacing(7);
-    
-    QHBoxLayout * filterLayout = new QHBoxLayout(filtersContainer);
-    filterLayout->setSpacing(0);
-    filterLayout->setMargin(0);
-
-    const int filterSpacing = 20;
-
-    // State button
-
-    QPushButton * btnState = new QPushButton(tr("Room state"));
-    btnState->setStyleSheet("QPushButton { padding: 2px 4px; } QPushButton:pressed { background-color: #ffcc00; border-color: #ffcc00; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; color: #11084A; }");
-    btnState->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
-    filterLayout->addWidget(btnState);
-    filterLayout->addSpacing(filterSpacing);
-
-    // State menu
-
-    QMenu * stateMenu = new QMenu(btnState);
-    showGamesInLobby = new QAction(QAction::tr("Show games in lobby"), stateMenu);
-    showGamesInLobby->setCheckable(true);
-    showGamesInLobby->setChecked(true);
-    showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
-    showGamesInProgress->setCheckable(true);
-    showGamesInProgress->setChecked(true);
-    stateMenu->addAction(showGamesInLobby);
-    stateMenu->addAction(showGamesInProgress);
-    btnState->setMenu(stateMenu);
-
     // Lobby chat
 
     chatWidget = new HWChatWidget(this, false);
--- a/QTfrontend/ui/page/pageroomslist.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageroomslist.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagescheme.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagescheme.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagescheme.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagescheme.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageselectweapon.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageselectweapon.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pageselectweapon.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pageselectweapon.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagesingleplayer.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagesingleplayer.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagesingleplayer.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagesingleplayer.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagetraining.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagetraining.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagetraining.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagetraining.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagevideos.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagevideos.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/page/pagevideos.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/page/pagevideos.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/FreqSpinBox.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/FreqSpinBox.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/FreqSpinBox.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/FreqSpinBox.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/HistoryLineEdit.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/HistoryLineEdit.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/HistoryLineEdit.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/HistoryLineEdit.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/SmartLineEdit.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/SmartLineEdit.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/SmartLineEdit.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/SmartLineEdit.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/SquareLabel.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/SquareLabel.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/SquareLabel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/SquareLabel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/about.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/about.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,7 +35,9 @@
 #ifdef VIDEOREC
 extern "C"
 {
-#include "libavutil/avutil.h"
+    #include "libavcodec/version.h"
+    #include "libavformat/version.h"
+    #include "libavutil/avutil.h" // version.h only from 51.36.0
 }
 #endif
 
@@ -159,7 +161,15 @@
     libinfo.append(QString("<a href=\"http://qt-project.org/\">Qt</a> version: %1<br>").arg(QT_VERSION_STR));
 
 #ifdef VIDEOREC
-    libinfo.append(QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3<br>")
+    libinfo.append(QString("<a href=\"http://libav.org\">libavcodec</a> version: %1.%2.%3<br>")
+        .arg(LIBAVCODEC_VERSION_MAJOR)
+        .arg(LIBAVCODEC_VERSION_MINOR)
+        .arg(LIBAVCODEC_VERSION_MICRO));
+    libinfo.append(QString("<a href=\"http://libav.org\">libavformat</a> version: %1.%2.%3<br>")
+        .arg(LIBAVFORMAT_VERSION_MAJOR)
+        .arg(LIBAVFORMAT_VERSION_MINOR)
+        .arg(LIBAVFORMAT_VERSION_MICRO));
+    libinfo.append(QString("<a href=\"http://libav.org\">libavutil</a> version: %1.%2.%3<br>")
         .arg(LIBAVUTIL_VERSION_MAJOR)
         .arg(LIBAVUTIL_VERSION_MINOR)
         .arg(LIBAVUTIL_VERSION_MICRO));
--- a/QTfrontend/ui/widget/about.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/about.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/bgwidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/bgwidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/bgwidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/bgwidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/chatwidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -544,7 +544,8 @@
     QString hlRegExp("^(.* )?%1[^-a-z0-9_]*( .*)?$");
     QRegExp whitespace("\\s");
 
-    m_highlights.append(QRegExp(hlRegExp.arg(m_userNick.toLower())));
+    if (!m_userNick.isEmpty())
+        m_highlights.append(QRegExp(hlRegExp.arg(QRegExp::escape(m_userNick.toLower()))));
 
     QFile file(cfgdir->absolutePath() + "/" + m_userNick.toLower() + "_highlight.txt");
 
--- a/QTfrontend/ui/widget/chatwidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/chatwidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/databrowser.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/databrowser.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/databrowser.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/databrowser.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/drawmapwidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/drawmapwidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/drawmapwidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/drawmapwidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/feedbackdialog.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/feedbackdialog.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/feedbackdialog.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/feedbackdialog.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/fpsedit.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/fpsedit.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/fpsedit.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/fpsedit.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/frameTeam.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/frameTeam.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/frameTeam.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/frameTeam.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/gamecfgwidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hatbutton.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hatbutton.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hatbutton.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hatbutton.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hatprompt.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hatprompt.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hatprompt.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hatprompt.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hedgehogerWidget.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hedgehogerWidget.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Ulyanov Igor <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/hedgehogerWidget.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/hedgehogerWidget.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Ulyanov Igor <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/igbox.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/igbox.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/igbox.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/igbox.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/keybinder.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/keybinder.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/keybinder.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/keybinder.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/lineeditcursor.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/lineeditcursor.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/lineeditcursor.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/lineeditcursor.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/mapContainer.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/mapContainer.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/qpushbuttonwithsound.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/qpushbuttonwithsound.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/roomnameprompt.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/roomnameprompt.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/roomnameprompt.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/roomnameprompt.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/seedprompt.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/seedprompt.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/seedprompt.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/seedprompt.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/selectWeapon.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/selectWeapon.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/teamselect.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/teamselect.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/teamselect.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/teamselect.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/teamselhelper.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/teamselhelper.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/teamselhelper.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/teamselhelper.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/themeprompt.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/themeprompt.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/themeprompt.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/themeprompt.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/togglebutton.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/togglebutton.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/togglebutton.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/togglebutton.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/vertScrollArea.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/vertScrollArea.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/vertScrollArea.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/vertScrollArea.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/weaponItem.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/weaponItem.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui/widget/weaponItem.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui/widget/weaponItem.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui_hwform.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui_hwform.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/ui_hwform.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/ui_hwform.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/DataManager.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/DataManager.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/DataManager.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/DataManager.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/LibavInteraction.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/LibavInteraction.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/LibavInteraction.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/LibavInteraction.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/MessageDialog.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/MessageDialog.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/MessageDialog.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/MessageDialog.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/SDLInteraction.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/SDLInteraction.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/SDLInteraction.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/SDLInteraction.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/namegen.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/namegen.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Martin Minarik <ttsmj@pokec.sk>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/namegen.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/namegen.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2009 Martin Minarik <ttsmj@pokec.sk>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/CocoaInitializer.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/CocoaInitializer.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/CocoaInitializer.mm	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/CocoaInitializer.mm	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/InstallController.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/InstallController.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/InstallController.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/InstallController.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/M3Panel.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/M3Panel.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/M3Panel.mm	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/M3Panel.mm	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/SparkleAutoUpdater.mm	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/SparkleAutoUpdater.mm	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/xfire.cpp	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/xfire.cpp	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/QTfrontend/util/platform/xfire.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/QTfrontend/util/platform/xfire.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/README	Thu Jan 09 19:10:12 2014 +0100
+++ b/README	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 Hedgewars - a turn based strategy game.
 =======================================
 
-Copyright 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> and others.
+Copyright 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> and others.
 See QTfrontend/res/html/about.html and CREDITS for a complete list of authors.
 
 Licence:
--- a/cmake_modules/FindFFMPEG.cmake	Thu Jan 09 19:10:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-# Find ffmpeg/libav libraries (libavcodec, libavformat and libavutil)
-# Once done this will define
-#
-#  FFMPEG_FOUND             - system has libavcodec, libavformat, libavutil
-#  FFMPEG_INCLUDE_DIR       - the libav include directories
-#  FFMPEG_LIBRARIES         - the libav libraries
-#
-#  LIBAVCODEC_LIBRARY      - the libavcodec library
-#  LIBAVCODEC_INCLUDE_DIR  - the libavcodec include directory
-#  LIBAVFORMAT_LIBRARY     - the libavformat library
-#  LIBAVUTIL_LIBRARY       - the libavutil library
-#
-#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
-#  Modified for other libraries by Lasse Kärkkäinen <tronic>
-#  Modified for Hedgewars by Stepik777
-#  Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
-#
-#  Redistribution and use is allowed according to the terms of the New
-#  BSD license.
-#
-
-include(FindPackageHandleStandardArgs)
-
-
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
-    if(NOT LIBAVCODEC_INCLUDE_DIR OR NOT LIBAVCODEC_LIBRARY)
-        pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
-    endif()
-    if(NOT LIBAVFORMAT_LIBRARY)
-        pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
-    endif()
-    if(NOT LIBAVUTIL_LIBRARY)
-        pkg_check_modules(_FFMPEG_AVUTIL libavutil)
-    endif()
-endif(PKG_CONFIG_FOUND)
-
-find_path(LIBAVCODEC_INCLUDE_DIR
-    NAMES libavcodec/avcodec.h
-    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}    #pkg-config
-          /usr/include /usr/local/include    #system level
-          /opt/local/include /sw/include     #macports & fink
-    PATH_SUFFIXES libav ffmpeg
-)
-
-#TODO: add other include paths
-
-find_library(LIBAVCODEC_LIBRARY
-    NAMES avcodec
-    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}   #pkg-config
-          /usr/lib /usr/local/lib           #system level
-          /opt/local/lib /sw/lib            #macports & fink
-)
-
-find_library(LIBAVFORMAT_LIBRARY
-    NAMES avformat
-    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}  #pkg-config
-          /usr/lib /usr/local/lib           #system level
-          /opt/local/lib /sw/lib            #macports & fink
-)
-
-find_library(LIBAVUTIL_LIBRARY
-    NAMES avutil
-    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}    #pkg-config
-          /usr/lib /usr/local/lib           #system level
-          /opt/local/lib /sw/lib            #macports & fink
-)
-
-find_package_handle_standard_args(FFMPEG DEFAULT_MSG LIBAVCODEC_LIBRARY LIBAVCODEC_INCLUDE_DIR
-                                                     LIBAVFORMAT_LIBRARY
-                                                     LIBAVUTIL_LIBRARY
-                                                     )
-set(FFMPEG_INCLUDE_DIR ${LIBAVCODEC_INCLUDE_DIR}
-                       #TODO: add other include paths
-                       )
-set(FFMPEG_LIBRARIES ${LIBAVCODEC_LIBRARY}
-                     ${LIBAVFORMAT_LIBRARY}
-                     ${LIBAVUTIL_LIBRARY}
-                     )
-
-mark_as_advanced(FFMPEG_INCLUDE_DIR FFMPEG_LIBRARIES LIBAVCODEC_LIBRARY LIBAVCODEC_INCLUDE_DIR LIBAVFORMAT_LIBRARY LIBAVUTIL_LIBRARY)
-
-
--- a/cmake_modules/FindGLEW.cmake	Thu Jan 09 19:10:12 2014 +0100
+++ b/cmake_modules/FindGLEW.cmake	Tue Jan 21 22:38:13 2014 +0100
@@ -1,9 +1,9 @@
 # Find GLEW
 #
 # Once done this will define
-#  GLEW_FOUND - system has Sparkle
-#  GLEW_INCLUDE_DIR - the Sparkle include directory
-#  GLEW_LIBRARY - The library needed to use Sparkle
+#  GLEW_FOUND - system has GLEW
+#  GLEW_INCLUDE_DIR - the GLEW include directory
+#  GLEW_LIBRARY - The library needed to use GLEW
 # Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
 #
 # Distributed under the OSI-approved BSD License (the "License");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindLIBAV.cmake	Tue Jan 21 22:38:13 2014 +0100
@@ -0,0 +1,90 @@
+# Find ffmpeg/libav libraries (libavcodec, libavformat and libavutil)
+# Once done this will define
+#
+#  LIBAV_FOUND             - system has libavcodec, libavformat, libavutil
+#  LIBAV_INCLUDE_DIR       - libav include directories
+#  LIBAV_LIBRARIES         - libav libraries (libavcodec, libavformat, libavutil)
+#
+#  LIBAVCODEC_LIBRARY      - libavcodec library
+#  LIBAVCODEC_INCLUDE_DIR  - libavcodec include directory
+#  LIBAVFORMAT_LIBRARY     - libavformat library
+#  LIBAVUTIL_LIBRARY       - libavutil library
+#
+#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
+#  Modified for other libraries by Lasse Kärkkäinen <tronic>
+#  Modified for Hedgewars by Stepik777
+#  Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#
+
+include(FindPackageHandleStandardArgs)
+
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+    if(NOT LIBAVCODEC_INCLUDE_DIR OR NOT LIBAVCODEC_LIBRARY)
+        pkg_check_modules(_LIBAV_AVCODEC libavcodec)
+    endif()
+    if(NOT LIBAVFORMAT_LIBRARY)
+        pkg_check_modules(_LIBAV_AVFORMAT libavformat)
+    endif()
+    if(NOT LIBAVUTIL_LIBRARY)
+        pkg_check_modules(_LIBAV_AVUTIL libavutil)
+    endif()
+endif(PKG_CONFIG_FOUND)
+
+find_path(LIBAVCODEC_INCLUDE_DIR
+    NAMES libavcodec/avcodec.h
+    PATHS ${_LIBAV_AVCODEC_INCLUDE_DIRS}     #pkg-config
+          /usr/include /usr/local/include    #system level
+          /opt/local/include /sw/include     #macports & fink
+    PATH_SUFFIXES libav ffmpeg
+)
+
+#TODO: add other include paths
+
+find_library(LIBAVCODEC_LIBRARY
+    NAMES avcodec
+    PATHS ${_LIBAV_AVCODEC_LIBRARY_DIRS}    #pkg-config
+          /usr/lib /usr/local/lib           #system level
+          /opt/local/lib /sw/lib            #macports & fink
+)
+
+find_library(LIBAVFORMAT_LIBRARY
+    NAMES avformat
+    PATHS ${_LIBAV_AVFORMAT_LIBRARY_DIRS}   #pkg-config
+          /usr/lib /usr/local/lib           #system level
+          /opt/local/lib /sw/lib            #macports & fink
+)
+
+find_library(LIBAVUTIL_LIBRARY
+    NAMES avutil
+    PATHS ${_LIBAV_AVUTIL_LIBRARY_DIRS}     #pkg-config
+          /usr/lib /usr/local/lib           #system level
+          /opt/local/lib /sw/lib            #macports & fink
+)
+
+find_package_handle_standard_args(LIBAV DEFAULT_MSG LIBAVCODEC_LIBRARY
+                                                    LIBAVCODEC_INCLUDE_DIR
+                                                    LIBAVFORMAT_LIBRARY
+                                                    LIBAVUTIL_LIBRARY
+                                                    )
+set(LIBAV_INCLUDE_DIR ${LIBAVCODEC_INCLUDE_DIR}
+                      #TODO: add other include paths
+                      )
+set(LIBAV_LIBRARIES ${LIBAVCODEC_LIBRARY}
+                    ${LIBAVFORMAT_LIBRARY}
+                    ${LIBAVUTIL_LIBRARY}
+                    )
+
+mark_as_advanced(LIBAV_INCLUDE_DIR
+                 LIBAV_LIBRARIES
+                 LIBAVCODEC_LIBRARY
+                 LIBAVCODEC_INCLUDE_DIR
+                 LIBAVFORMAT_LIBRARY
+                 LIBAVUTIL_LIBRARY)
+
--- a/cmake_modules/cpackvars.cmake	Thu Jan 09 19:10:12 2014 +0100
+++ b/cmake_modules/cpackvars.cmake	Tue Jan 21 22:38:13 2014 +0100
@@ -84,6 +84,7 @@
     "cmake_uninstall\\\\.cmake$"
     "CMakeCache\\\\.txt$"
     "build_windows_.*\\\\.bat$"
+    "arch\\\\.c$"
     "^${CMAKE_CURRENT_SOURCE_DIR}/misc/liblua"
 #    "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/frontlib"
 #    "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/cmdlineClient"
--- a/gameServer/Actions.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/Actions.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -454,8 +454,14 @@
     checkerLogin _ False _ = processAction $ ByeClient $ loc "No checker rights"
     checkerLogin p True _ = do
         wp <- client's webPassword
-        processAction $
-            if wp == p then ModifyClient $ \c -> c{logonPassed = True} else ByeClient $ loc "Authentication failed"
+        chan <- client's sendChan
+        mapM_ processAction $
+            if wp == p then 
+                [ModifyClient $ \c -> c{logonPassed = True}
+                , AnswerClients [chan] ["LOGONPASSED"]
+                ]
+                else 
+                [ByeClient $ loc "Authentication failed"]
     playerLogin p a contr = do
         chan <- client's sendChan
         mapM_ processAction [
@@ -524,7 +530,7 @@
 
 processAction (BanNick n seconds reason) = do
     currentTime <- io getCurrentTime
-    let msg =
+    let msg = 
             if seconds > 60 * 60 * 24 * 365 then
                 B.concat ["Permanent ban (", reason, ")"]
                 else
@@ -569,13 +575,18 @@
         return ci
 
     modify (\s -> s{clientIndex = Just newClId})
-    mapM_ processAction
-        [
-            AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
-            , CheckBanned True
-            , AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl)
-        ]
+
+    jm <- gets joinsMonitor
+    pass <- io $ joinsSentry jm (host cl) (connectTime cl)
 
+    if pass then
+        mapM_ processAction
+            [
+                CheckBanned True
+                , AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
+            ]
+        else
+        processAction $ ByeClient $ loc "Reconnected too fast"
 
 processAction (AddNick2Bans n reason expiring) = do
     processAction $ ModifyServerInfo (\s -> s{bans = BanByNick n reason expiring : bans s})
@@ -760,3 +771,11 @@
             , [AnswerClients [c] $ "EM" : roundMsgs']
             , [AnswerClients [c] ["KICKED"]]
             ]
+
+
+processAction Cleanup = do
+    jm <- gets joinsMonitor
+    
+    io $ do
+        t <- getCurrentTime
+        cleanup jm t
--- a/gameServer/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -16,6 +16,7 @@
     HWProtoLobbyState.hs
     HWProtoNEState.hs
     HandlerUtils.hs
+    JoinsMonitor.hs
     NetRoutines.hs
     Opts.hs
     RoomsAndClients.hs
@@ -26,11 +27,11 @@
     hedgewars-server.hs
     )
 
-set(hwserv_main ${CMAKE_SOURCE_DIR}/gameServer/hedgewars-server.hs)
+set(hwserv_main ${hedgewars_SOURCE_DIR}/gameServer/hedgewars-server.hs)
 
 set(ghc_flags
     --make ${hwserv_main}
-    -i${CMAKE_CURRENT_SOURCE_DIR}
+    -i${hedgewars_SOURCE_DIR}/gameServer
     -o ${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}
     -odir ${CMAKE_CURRENT_BINARY_DIR}
     -hidir ${CMAKE_CURRENT_BINARY_DIR}
--- a/gameServer/CoreTypes.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/CoreTypes.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -16,7 +16,6 @@
 -----------------------
 import RoomsAndClients
 
-
 #if __GLASGOW_HASKELL__ < 706
 instance NFData B.ByteString
 #endif
@@ -78,6 +77,7 @@
     | Random [ClientChan] [B.ByteString]
     | QueryReplay B.ByteString
     | ShowReplay B.ByteString
+    | Cleanup
 
 type ClientChan = Chan [B.ByteString]
 
@@ -212,8 +212,8 @@
         )
         (
             Map.fromList $ Prelude.zip
-                ["SCHEME", "SCRIPT"]
-                [["Default"], ["Normal"]]
+                ["SCHEME", "SCRIPT", "Theme"]
+                [["Default"], ["Normal"], ["Theme"]]
         )
 
 
--- a/gameServer/HWProtoInRoomState.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/HWProtoInRoomState.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -15,6 +15,39 @@
 import RoomsAndClients
 import EngineInteraction
 
+
+startGame :: Reader (ClientIndex, IRnC) [Action]
+startGame = do
+    (ci, rnc) <- ask
+    cl <- thisClient
+    rm <- thisRoom
+    chans <- roomClientsChans
+
+    let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci
+    let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
+
+    if (playersIn rm == readyPlayers rm || clientProto cl > 43) && not (isJust $ gameInfo rm) then
+        if enoughClans rm then
+            return [
+                ModifyRoom
+                    (\r -> r{
+                        gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm)
+                        }
+                    )
+                , AnswerClients chans ["RUN_GAME"]
+                , SendUpdateOnThisRoom
+                , AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks
+                , ModifyRoomClients (\c -> c{isInGame = True})
+                ]
+            else
+            return [Warning $ loc "Less than two clans!"]
+        else
+        return []
+    where
+        enoughClans = not . null . drop 1 . group . map teamcolor . teams
+
+
+
 handleCmd_inRoom :: CmdHandler
 
 handleCmd_inRoom ["CHAT", msg] = do
@@ -173,48 +206,29 @@
 
 handleCmd_inRoom ["TOGGLE_READY"] = do
     cl <- thisClient
-    chans <- roomClientsChans
-
-    return [
-        ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}),
-        ModifyClient (\c -> c{isReady = not $ isReady cl}),
-        AnswerClients chans $ if clientProto cl < 38 then
-                [if isReady cl then "NOT_READY" else "READY", nick cl]
-                else
-                ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
-        ]
-
-
-handleCmd_inRoom ["START_GAME"] = do
-    (ci, rnc) <- ask
-    cl <- thisClient
     rm <- thisRoom
     chans <- roomClientsChans
 
-    let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci
-    let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
+    (ci, rnc) <- ask
+    let ri = clientRoom rnc ci
+    let unreadyClients = filter (not . isReady) . map (client rnc) $ roomClients rnc ri
+
+    gs <- if (not $ isReady cl) && (isSpecial rm) && (unreadyClients == [cl]) then startGame else return []
 
-    if isMaster cl && (playersIn rm == readyPlayers rm || clientProto cl > 43) && not (isJust $ gameInfo rm) then
-        if enoughClans rm then
-            return [
-                ModifyRoom
-                    (\r -> r{
-                        gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm)
-                        }
-                    )
-                , AnswerClients chans ["RUN_GAME"]
-                , SendUpdateOnThisRoom
-                , AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks
-                , ModifyRoomClients (\c -> c{isInGame = True})
-                ]
-            else
-            return [Warning $ loc "Less than two clans!"]
-        else
-        return []
-    where
-        enoughClans = not . null . drop 1 . group . map teamcolor . teams
+    return $ 
+        ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)})
+        : ModifyClient (\c -> c{isReady = not $ isReady cl})
+        : (AnswerClients chans $ if clientProto cl < 38 then
+                [if isReady cl then "NOT_READY" else "READY", nick cl]
+                else
+                ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl])
+        : gs
 
 
+handleCmd_inRoom ["START_GAME"] = do
+    cl <- thisClient
+    if isMaster cl then startGame else return []
+
 handleCmd_inRoom ["EM", msg] = do
     cl <- thisClient
     rm <- thisRoom
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gameServer/JoinsMonitor.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -0,0 +1,43 @@
+{-# LANGUAGE BangPatterns #-}
+
+module JoinsMonitor(
+    JoinsMonitor
+    , newJoinMonitor
+    , cleanup
+    , joinsSentry
+    ) where
+
+import qualified Data.Map as Map
+import Data.Time
+import Data.IORef
+import qualified Data.ByteString as B
+import Data.Maybe
+import Control.Monad
+
+newtype JoinsMonitor = JoinsMonitor (IORef (Map.Map B.ByteString [UTCTime]))
+
+
+newJoinMonitor :: IO JoinsMonitor
+newJoinMonitor = do
+    ioref <- newIORef Map.empty
+    return (JoinsMonitor ioref)
+
+
+cleanup :: JoinsMonitor -> UTCTime -> IO ()
+cleanup (JoinsMonitor ref) time = modifyIORef ref f
+    where
+        f = Map.mapMaybe (\v -> let v' = takeWhile (\t -> diffUTCTime time t < 60*60) v in if null v' then Nothing else Just v')
+
+
+joinsSentry :: JoinsMonitor -> B.ByteString -> UTCTime -> IO Bool
+joinsSentry (JoinsMonitor ref) host time = do
+    m <- readIORef ref
+    let lastJoins = map (diffUTCTime time) $ Map.findWithDefault [] host m
+    let last30sec = length $ takeWhile (< 30) lastJoins
+    let last2min = length $ takeWhile (< 120) lastJoins
+    let last10min = length $ takeWhile (< 600) lastJoins
+    let pass = last30sec < 2 && last2min < 4 && last10min < 6
+
+    when pass $ writeIORef ref $ Map.alter (Just . (:) time . fromMaybe []) host m
+
+    return pass
--- a/gameServer/OfficialServer/checker.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/OfficialServer/checker.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -148,8 +148,8 @@
     onPacket :: Chan Message -> [B.ByteString] -> IO ()
     onPacket _ ("CONNECTED":_) = do
         answer ["CHECKER", protocolNumber, l, p]
-        answer ["READY"]
     onPacket _ ["PING"] = answer ["PONG"]
+    onPacket _ ["LOGONPASSED"] = answer ["READY"]
     onPacket chan ("REPLAY":msgs) = do
         checkReplay chan msgs
         warningM "Check" "Started check"
--- a/gameServer/ServerCore.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/ServerCore.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -62,7 +62,9 @@
 
         TimerAction tick ->
                 mapM_ processAction $
-                    PingAll : [StatsAction | even tick]
+                    PingAll 
+                    : [StatsAction | even tick] 
+                    ++ [Cleanup | tick `mod` 100 == 0]
 
 
 startServer :: ServerInfo -> IO ()
@@ -79,5 +81,6 @@
     startDBConnection si
 
     rnc <- newRoomsAndClients newRoom
+    jm <- newJoinMonitor
 
-    evalStateT mainLoop (ServerState Nothing si Set.empty rnc)
+    evalStateT mainLoop (ServerState Nothing si Set.empty rnc jm)
--- a/gameServer/ServerState.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/ServerState.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,7 @@
 module ServerState
     (
     module RoomsAndClients,
+    module JoinsMonitor,
     clientRoomA,
     ServerState(..),
     client's,
@@ -17,12 +18,14 @@
 ----------------------
 import RoomsAndClients
 import CoreTypes
+import JoinsMonitor
 
 data ServerState = ServerState {
         clientIndex :: !(Maybe ClientIndex),
         serverInfo :: !ServerInfo,
         removedClients :: !(Set.Set ClientIndex),
-        roomsClients :: !MRnC
+        roomsClients :: !MRnC,
+        joinsMonitor :: !JoinsMonitor
     }
 
 
--- a/gameServer/hedgewars-server.cabal	Thu Jan 09 19:10:12 2014 +0100
+++ b/gameServer/hedgewars-server.cabal	Tue Jan 21 22:38:13 2014 +0100
@@ -16,6 +16,7 @@
 
   Build-depends:
     base >= 4.3,
+    unix,
     containers,
     vector,
     bytestring,
--- a/hedgewars/ArgParsers.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/ArgParsers.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
- 
+
 {$INCLUDE "options.inc"}
 
 unit ArgParsers;
@@ -45,7 +45,6 @@
     WriteLn(stdout, '          \/////////////          \/////////  \///////////      ');
     WriteLn(stdout, '                                                                ');
     WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student ');
-    WriteLn(stdout, '             ASCII Art easter egg idea by @sheepluva            ');
     WriteLn(stdout, '                                                                ');
 end;
 
@@ -186,18 +185,18 @@
 procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); forward;
 
 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean;
-const videoArray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
-      audioArray: array [0..2] of string = ('--volume','--nomusic','--nosound');
-      otherArray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
-      mediaArray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
-      allArray:   array [0..17] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
-      reallyAll:  array [0..34] of shortstring = (
+const videoArray: Array [1..5] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
+      audioArray: Array [1..3] of string = ('--volume','--nomusic','--nosound');
+      otherArray: Array [1..3] of string = ('--locale','--fullscreen','--showfps');
+      mediaArray: Array [1..10] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
+      allArray: Array [1..18] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
+      reallyAll: array[0..35] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   {internal}    '--internal', '--port', '--recorder', '--landpreview',
-  {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
+  {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
 var cmdIndex: byte;
 begin
     parseParameter:= false;
@@ -242,13 +241,14 @@
         {--stats-only}          28 : statsOnlyGame();
         {--gci}                 29 : GciEasterEgg();
         {--help}                30 : DisplayUsage();
-        {--no-teamtag}          31 : cTagsMask := cTagsMask and (not htTeamName);
-        {--no-hogtag}           32 : cTagsMask := cTagsMask and (not htName);
-        {--no-healthtag}        33 : cTagsMask := cTagsMask and (not htHealth);
-        {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent
+        {--no-teamtag}          31 : cTagsMask := cTagsMask and not htTeamName;
+        {--no-hogtag}           32 : cTagsMask := cTagsMask and not htName;
+        {--no-healthtag}        33 : cTagsMask := cTagsMask and not htHealth;
+        {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent;
+        {--lua-test}            35 : begin cTestLua := true; cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
     else
         begin
-        //Asusme the first "non parameter" is the replay file, anything else is invalid
+        //Assume the first "non parameter" is the replay file, anything else is invalid
         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
             recordFileName := cmd
         else
@@ -354,7 +354,7 @@
         GameType := gmtSyntax;
         end;
 
-    if (not isInternal) and (recordFileName = '') then
+    if (not cTestLua) and (not isInternal) and (recordFileName = '') then
         begin
         WriteLn(stderr, 'You must specify a replay file');
         GameType := gmtSyntax;
--- a/hedgewars/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -20,6 +20,14 @@
     endif()
 endif(UNIX)
 
+# convert list into pascal array
+list(LENGTH FONTS_DIRS ndirs)
+set(FONTS_DIRS_ARRAY "array [0..${ndirs}] of PChar = (")
+foreach(fontdir ${FONTS_DIRS})
+    set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\n'${fontdir}',")
+endforeach(fontdir)
+set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\nnil);\n")
+
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
@@ -94,17 +102,10 @@
     )
 
 
-include(${CMAKE_MODULE_PATH}/utils.cmake)
-#opengl 2
-IF(${GL2})
-    set(pascal_flags "-dGL2" ${pascal_flags})
-    message(STATUS "Building using OpenGL 2")
-ENDIF(${GL2})
-
-if (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.2 OR # older versions are just ancient
-    (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.6 AND APPLE)) # because of 64bit and opengl bindings
+if(${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.2 OR # older versions are just ancient
+   (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.6 AND APPLE)) # because of 64bit and opengl bindings
     message(FATAL_ERROR "Your FreePascal installation is too old (fpc ${CMAKE_Pascal_COMPILER_VERSION})!")
-elseif(CMAKE_Pascal_COMPILER_VERSION VERSION_GREATER 2.4)
+elseif(${CMAKE_Pascal_COMPILER_VERSION} VERSION_GREATER 2.4)
     #enable INLINE only with a recent version of fpc
     add_flag_prepend(CMAKE_Pascal_FLAGS_RELEASE -Si)
 endif()
@@ -113,13 +114,13 @@
 add_flag_append(CMAKE_Pascal_FLAGS "-Fl${LIBRARY_OUTPUT_PATH}")
 
 #DEPENDECIES AND EXECUTABLES SECTION
-if(NOT ${BUILD_ENGINE_LIBRARY} AND APPLE)
+if(APPLE AND (NOT BUILD_ENGINE_LIBRARY))
     #on OSX we need to provide the SDL_main() function when building as executable
     add_subdirectory(sdlmain)
     list(APPEND HW_LINK_LIBS SDLmain)
 endif()
 
-if(FFMPEG_FOUND)
+if(LIBAV_FOUND)
     add_subdirectory(avwrapper)
     list(APPEND HW_LINK_LIBS avwrapper)
     add_definitions(-dUSE_VIDEO_RECORDING)
@@ -136,7 +137,7 @@
     add_definitions(-dPNG_SCREENSHOTS)
 endif()
 
-if(LUA_FOUND AND LUA_SYSTEM)
+if(LUA_SYSTEM)
     get_filename_component(LUA_LIBRARY_DIR ${LUA_LIBRARY} PATH)
     get_filename_component(LUA_LIBRARY_NAME ${LUA_LIBRARY} NAME)
     #NAME_WE would strip the .1 (or .2) next to the ".so"
@@ -148,7 +149,7 @@
     add_flag_append(CMAKE_Pascal_FLAGS "-XLAlua=${lua_output_name}")
 endif()
 
-if(PHYSFS_FOUND)
+if(PHYSFS_SYSTEM)
     get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY} PATH)
     add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY}")
 else()
@@ -174,10 +175,15 @@
     add_definitions(-dSDL_IMAGE_NEWER)
 endif(HAVE_IMGINIT)
 
-if(NOT (SDL_VERSION VERSION_LESS 2.0))
+if(${SDL_VERSION} VERSION_GREATER 1.3)
     add_definitions(-dSDL2)
 endif()
 
+#opengl 2
+IF(GL2)
+    add_definitions(-dGL2)
+ENDIF(GL2)
+
 #needs to be last
 add_definitions(-dDEBUGFILE)
 
@@ -192,7 +198,7 @@
 #SOURCE AND PROGRAMS SECTION
 if(BUILD_ENGINE_LIBRARY)
     message("***Engine will be built as library (experimental)***")
-    if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
+    if(APPLE AND ${current_macosx_version} VERSION_GREATER "10.5")
         # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
         add_flag_prepend(CMAKE_Pascal_FLAGS "-k-no_order_inits")
     endif()
--- a/hedgewars/LuaPas.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/LuaPas.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -138,7 +138,7 @@
     LUA_ENVIRONINDEX  = -10001;
     LUA_GLOBALSINDEX  = -10002;
 
-   
+
 function lua_upvalueindex(idx : LongInt) : LongInt;   // a marco
 
 
@@ -150,7 +150,7 @@
     LUA_ERRMEM    = 4;
     LUA_ERRERR    = 5;
 
-   
+
 type
    lua_CFunction = function(L : Plua_State) : LongInt; cdecl;
 
@@ -191,13 +191,13 @@
     (* type for integer functions *)
     lua_Integer = LUA_INTEGER_;
 
-   
+
 (*
 ** state manipulation
 *)
 function  lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State;
     cdecl; external LuaLibName;
-    
+
 procedure lua_close(L: Plua_State);
     cdecl; external LuaLibName;
 function  lua_newthread(L : Plua_State) : Plua_State;
@@ -212,22 +212,22 @@
 *)
 function  lua_gettop(L : Plua_State) : LongInt;
     cdecl; external LuaLibName;
-    
+
 procedure lua_settop(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushvalue(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_remove(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_insert(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_replace(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 function  lua_checkstack(L : Plua_State; sz : LongInt) : LongBool;
     cdecl; external LuaLibName;
 
@@ -240,55 +240,55 @@
 *)
 function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_isstring(L : Plua_State; idx : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_type(L : Plua_State; idx : LongInt) : LongInt;
     cdecl; external LuaLibName;
 
 function lua_typename(L : Plua_State; tp : LongInt) : PChar;
     cdecl; external LuaLibName;
-    
+
 function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool;
     cdecl; external LuaLibName;
 
 function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number;
     cdecl; external LuaLibName;
-    
+
 function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer;
     cdecl; external LuaLibName;
-    
+
 function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_tolstring(L : Plua_State; idx : LongInt; len : Psize_t) : PChar;
     cdecl; external LuaLibName;
 
 function lua_objlen(L : Plua_State; idx : LongInt) : size_t;
     cdecl; external LuaLibName;
-    
+
 function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction;
     cdecl; external LuaLibName;
-    
+
 function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer;
     cdecl; external LuaLibName;
-    
+
 function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State;
     cdecl; external LuaLibName;
-    
+
 function lua_topointer(L : Plua_State; idx : LongInt) : Pointer;
     cdecl; external LuaLibName;
 
@@ -298,35 +298,35 @@
 *)
 procedure lua_pushnil(L : Plua_State);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushnumber(L : Plua_State; n : lua_Number);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushinteger(L : Plua_State; n : lua_Integer);
     cdecl; external LuaLibName;
 
 procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushstring(L : Plua_State; const s : PChar);
     cdecl; external LuaLibName;
-    
+
 function  lua_pushvfstring(L : Plua_State;
     const fmt : PChar; argp : Pointer) : PChar;
     cdecl; external LuaLibName;
-    
+
 function  lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs;
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushboolean(L : Plua_State; b : LongBool);
     cdecl; external LuaLibName;
-    
+
 procedure lua_pushlightuserdata(L : Plua_State; p : Pointer);
     cdecl; external LuaLibName;
-    
+
 function  lua_pushthread(L : Plua_state) : Cardinal;
     cdecl; external LuaLibName;
 
@@ -342,19 +342,19 @@
 
 procedure lua_rawget(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_rawgeti(L : Plua_State; idx, n : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_createtable(L : Plua_State; narr, nrec : LongInt);
     cdecl; external LuaLibName;
-    
+
 function  lua_newuserdata(L : Plua_State; sz : size_t) : Pointer;
     cdecl; external LuaLibName;
-    
+
 function  lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool;
     cdecl; external LuaLibName;
-    
+
 procedure lua_getfenv(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
 
@@ -370,13 +370,13 @@
 
 procedure lua_rawset(L : Plua_State; idx : LongInt);
     cdecl; external LuaLibName;
-    
+
 procedure lua_rawseti(L : Plua_State; idx , n: LongInt);
     cdecl; external LuaLibName;
-    
+
 function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool;
     cdecl; external LuaLibName;
-    
+
 function lua_setfenv(L : Plua_State; idx : LongInt): LongBool;
     cdecl; external LuaLibName;
 
@@ -385,16 +385,16 @@
 *)
 procedure lua_call(L : Plua_State; nargs, nresults : LongInt);
     cdecl; external LuaLibName;
-    
+
 function  lua_pcall(L : Plua_State; nargs, nresults, errfunc : LongInt) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function  lua_cpcall(L : Plua_State; func : lua_CFunction; ud : Pointer) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function  lua_load(L : Plua_State; reader : lua_Reader; dt : Pointer; const chunkname : PChar) : LongInt;
     cdecl; external LuaLibName;
-    
+
 
 function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt;
     cdecl; external LuaLibName;
@@ -405,10 +405,10 @@
 *)
 function lua_yield(L : Plua_State; nresults : LongInt) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function lua_resume(L : Plua_State; narg : LongInt) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function lua_status(L : Plua_State) : LongInt;
     cdecl; external LuaLibName;
 
@@ -425,7 +425,7 @@
     LUA_GCSTEP       = 5;
     LUA_GCSETPAUSE   = 6;
     LUA_GCSETSTEPMUL = 7;
-   
+
 function lua_gc(L : Plua_State; what, data : LongInt) : LongInt;
     cdecl; external LuaLibName;
 
@@ -443,7 +443,7 @@
 
 function  lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc;
     cdecl; external LuaLibName;
-    
+
 procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer);
     cdecl; external LuaLibName;
 
@@ -541,25 +541,25 @@
 
 function lua_getstack(L : Plua_State; level : LongInt; ar : Plua_Debug) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function lua_getinfo(L : Plua_State; const what : PChar; ar: Plua_Debug): LongInt;
     cdecl; external LuaLibName;
-    
+
 function lua_getlocal(L : Plua_State; ar : Plua_Debug; n : LongInt) : PChar;
     cdecl; external LuaLibName;
-    
+
 function lua_setlocal(L : Plua_State; ar : Plua_Debug; n : LongInt) : PChar;
     cdecl; external LuaLibName;
-    
+
 function lua_getupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
     cdecl; external LuaLibName;
-    
+
 function lua_setupvalue(L : Plua_State; funcindex, n : LongInt) : PChar;
     cdecl; external LuaLibName;
 
 function lua_sethook(L : Plua_State; func : lua_Hook; mask, count: LongInt): LongInt;
     cdecl; external LuaLibName;
-  
+
 {$IFDEF LUA_GETHOOK}
 function lua_gethook(L : Plua_State) : lua_Hook;
     cdecl; external LuaLibName;
@@ -567,7 +567,7 @@
 
 function lua_gethookmask(L : Plua_State) : LongInt;
     cdecl; external LuaLibName;
-    
+
 function lua_gethookcount(L : Plua_State) : LongInt;
     cdecl; external LuaLibName;
 
--- a/hedgewars/PNGh.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/PNGh.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/SDLh.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/SDLh.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -235,11 +235,7 @@
     SDL_SRCCOLORKEY = $00001000;
     SDL_RLEACCEL    = $00004000;
     SDL_SRCALPHA    = $00010000;
- {$IFDEF PAS2C}
-    SDL_ANYFORMAT   = $10000000;
- {$ELSE}
     SDL_ANYFORMAT   = $00100000;
- {$ENDIF}
     SDL_HWPALETTE   = $20000000;
     SDL_DOUBLEBUF   = $40000000;
     SDL_FULLSCREEN  = $80000000;
@@ -409,24 +405,24 @@
         pitch : {$IFDEF SDL2}LongInt{$ELSE}Word{$ENDIF};
         pixels: Pointer;
 {$IFDEF PAS2C}
-        hwdata:Pointer;
-        clip_rect:TSDL_Rect;
-        unsed1:LongWord;
-        locked:LongWord;
-        map:Pointer;
-        format_version:Longword;
-        refcount:LongInt;
-        offset: LongInt;
+        hwdata   : Pointer;
+        clip_rect: TSDL_Rect;
+        unsed1   : LongWord;
+        locked   : LongWord;
+        map      : Pointer;
+        format_version: Longword;
+        refcount : LongInt;
+        offset   : LongInt;
 {$ELSE}
 {$IFDEF SDL2}
-        userdata: Pointer;
-        locked: LongInt;
-        lock_data: Pointer;
-        clip_rect: TSDL_Rect;
-        map: Pointer;
-        refcount: LongInt;
+        userdata  : Pointer;
+        locked    : LongInt;
+        lock_data : Pointer;
+        clip_rect : TSDL_Rect;
+        map       : Pointer;
+        refcount  : LongInt;
 {$ELSE}
-        offset: LongInt;
+        offset : LongInt;
 {$ENDIF}
 {$ENDIF}
         end;
@@ -1196,7 +1192,7 @@
 {$IFDEF SDL2}
         ((surface^.flags and SDL_RLEACCEL) <> 0)
 {$ELSE}
-        {$IFNDEF WEBGL}( surface^.offset <> 0 ) or {$ENDIF}(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
+        ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
 {$ENDIF}
 end;
 
--- a/hedgewars/adler32.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/adler32.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -3,7 +3,6 @@
 {ZLib - Adler32 checksum function}
 
 interface
-uses uTypes;
 
 (*************************************************************************
 
--- a/hedgewars/avwrapper/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/avwrapper/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -1,14 +1,14 @@
-#FFMPEG/Libav libraries have been searched already in main CMakeLists.txt
+#libraries have already been searched in main CMakeLists.txt
 
 # TODO: this check is only for SDL < 2
 # fpc will take care of linking but we need to have this library installed
 find_package(GLUT REQUIRED)
 
-include_directories(${FFMPEG_INCLUDE_DIR})
+include_directories(${LIBAV_INCLUDE_DIR})
 
 add_library(avwrapper avwrapper.c)
 #TODO: find good VERSION and SOVERSION values
-target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
+target_link_libraries(avwrapper ${LIBAV_LIBRARIES})
 install(TARGETS avwrapper RUNTIME DESTINATION ${target_binary_install_dir}
                           LIBRARY DESTINATION ${target_library_install_dir}
                           ARCHIVE DESTINATION ${target_library_install_dir})
--- a/hedgewars/avwrapper/avwrapper.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/avwrapper/avwrapper.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 /*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/config.inc.in	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/config.inc.in	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,3 +26,8 @@
       cRevisionString = '${HEDGEWARS_REVISION}';
       cHashString = '${HEDGEWARS_HASH}';
       cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';
+{$IFDEF PAS2C}
+      cFontsPaths = '';
+{$ELSE}
+      cFontsPaths: ${FONTS_DIRS_ARRAY}
+{$ENDIF}
--- a/hedgewars/hwLibrary.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/hwLibrary.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/hwengine.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/hwengine.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,7 +36,6 @@
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
      {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
      {$IFDEF ANDROID}, GLUnit{$ENDIF}
-     {$IFDEF WEBGL}, uWeb{$ENDIF}
      ;
 
 {$IFDEF HWLIBRARY}
@@ -53,20 +52,6 @@
 procedure freeEverything(complete:boolean); forward;
 {$ENDIF}
 
-{$IFDEF WEBGL}
-procedure playFile(path: PChar); forward;
-function isEngineRunning():Integer; forward;
-procedure shutdown();forward;
-function getRealTicks():Integer; forward;
-procedure mainhook(); forward;
-var
-    args: array[0..3] of PChar;
-    PrevTime, CurrTime: LongInt;
-    isTerminated: boolean;
-    prevFocusState: boolean;
-    isRunning : boolean;
-{$ENDIF}
-
 ///////////////////////////////////////////////////////////////////////////////
 function DoTimer(Lag: LongInt): boolean;
 var s: shortstring;
@@ -108,12 +93,8 @@
         gsConfirm, gsGame, gsChat:
             begin
             if not cOnlyStats then
-{$IFDEF WEBGL}
-                drawworld_hook();
-{$ELSE}
                 // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible
                 DrawWorld(Lag);
-{$ENDIF}
             DoGameTick(Lag);
             if not cOnlyStats then ProcessVisualGears(Lag);
             end;
@@ -160,26 +141,18 @@
 ///////////////////////////////////////////////////////////////////////////////
 procedure MainLoop;
 var event: TSDL_Event;
-{$IFNDEF WEBGL}
-    PrevTime, CurrTime: LongInt;
+    PrevTime, CurrTime: LongWord;
     isTerminated: boolean;
 {$IFDEF SDL2}
     previousGameState: TGameState;
 {$ELSE}
     prevFocusState: boolean;
 {$ENDIF}
-
-{$ENDIF}
-
 begin
-
-{$IFNDEF WEBGL}
     isTerminated:= false;
     PrevTime:= SDL_GetTicks;
     while isTerminated = false do
     begin
-{$ENDIF}
-
         SDL_PumpEvents();
 
         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL2}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
@@ -310,22 +283,11 @@
         begin
             isTerminated:= isTerminated or DoTimer(CurrTime - PrevTime);
             PrevTime:= CurrTime;
-            {$IFDEF WEBGL}
-            if not isTerminated then
-                mainloop_hook();
-            else
-            begin
-                freeEverything(true);
-                isRunning := false;
-            end
-            {$ENDIF}
         end
-        else {$IFNDEF WEBGL}SDL_Delay(1){$ELSE}mainloop_hook(){$ENDIF};
+        else SDL_Delay(1);
         IPCCheckSock();
 
-{$IFNDEF WEBGL}
     end;
-{$ENDIF}
 end;
 
 {$IFDEF USE_VIDEO_RECORDING}
@@ -366,10 +328,6 @@
 //var p: TPathType;
 var s: shortstring;
     i: LongInt;
-{$IFDEF WEBGL}
-    l:TResourceList;
-{$ENDIF}
-
 begin
 {$IFDEF HWLIBRARY}
     preInitEverything();
@@ -430,13 +388,20 @@
 
     WriteLnToConsole(msgGettingConfig);
 
-    if recordFileName = '' then
+    if cTestLua then
         begin
-        InitIPC;
-        SendIPCAndWaitReply(_S'C');        // ask for game config
+        ParseCommand('script ' + cScriptName, true);
         end
     else
-        LoadRecordFromFile(recordFileName);
+        begin
+        if recordFileName = '' then
+            begin
+            InitIPC;
+            SendIPCAndWaitReply(_S'C');        // ask for game config
+            end
+        else
+            LoadRecordFromFile(recordFileName);
+        end;
 
     ScriptOnGameInit;
     s:= 'eproto ' + inttostr(cNetProtoVersion);
@@ -463,20 +428,9 @@
     end;
 {$ENDIF}
 
-{$IFDEF WEBGL}
-    l := generateResourceList();
-    clear_filelist_hook();
-    for i:= 0 to l.count - 1 do
-    add_file_hook(PChar(l.files[i] + '.png'));
-    isTerminated := false;
-    isRunning := true;
-    PrevTime := SDL_GetTicks();
-    idb_loader_hook();
-{$ELSE}
     MainLoop;
     // clean up all the memory allocated
     freeEverything(true);
-{$ENDIF}
 end;
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -504,6 +458,7 @@
 
     if complete then
     begin
+        uLocale.initModule;
         uPhysFSLayer.initModule;
         uTextures.initModule;
 {$IFDEF ANDROID}GLUnit.initModule;{$ENDIF}
@@ -535,7 +490,7 @@
 procedure freeEverything (complete:boolean);
 begin
     if complete then
-    begin
+        begin
         WriteLnToConsole('Freeing resources...');
         uAI.freeModule;             // AI things need to be freed first
         uAIMisc.freeModule;         //stub
@@ -560,7 +515,8 @@
 {$IFDEF ANDROID}GLUnit.freeModule;{$ENDIF}
         uTextures.freeModule;
         uPhysFSLayer.freeModule;
-    end;
+        uLocale.freeModule;
+        end;
 
     uIO.freeModule;
     uLand.freeModule;
@@ -599,17 +555,10 @@
 ///////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////// m a i n ///////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
-{$IFDEF WEBGL}
-procedure hwmain(argc:Integer; argv:PPChar);
-{$ENDIF}
 begin
 {$IFDEF PAS2C}
     // workaround for pascal's ParamStr and ParamCount
     init(argc, argv);
-{$IFDEF WEBGL}
-    // patch emscripten's SDL implementation
-    SDL_InitPatch();
-{$ENDIF}
 {$ENDIF}
     preInitEverything();
     cTagsMask:= htTeamName or htName or htHealth; // this one doesn't fit nicely w/ reset of other variables. suggestions welcome
@@ -622,61 +571,10 @@
 
     // return 1 when engine is not called correctly
     {$IFDEF PAS2C}
-       {$IFNDEF WEBGL}
-       exit(LongInt(GameType = gmtSyntax));
-       {$ENDIF}
+    exit(LongInt(GameType = gmtSyntax));
     {$ELSE}
-       halt(LongInt(GameType = gmtSyntax));
+    halt(LongInt(GameType = gmtSyntax));
     {$ENDIF}
 
-
-{$IFDEF WEBGL}
-end;
-
-// hook
-procedure playFile(path: PChar);
-begin
-    args[0] := PChar('');
-    args[1] := PChar('');
-    args[2] := PChar('Data');
-    args[3] := path;
-    hwmain(4, args);
-end;
-
-// hook
-function isEngineRunning:Integer;
-begin
-    isEngineRunning := isRunning;
-end;
-
-// hook
-procedure shutdown;
-begin
-    GameState := gsExit;
-end;
-
-// hook
-function getRealTicks():Integer;
-begin
-    getRealTicks := RealTicks;
-end;
-
-// main
-begin
-    isRunning := false;
-
-    // avoid hooks to be eliminated by optimizer
-    if argc = 1234 then
-    begin
-        mainhook();
-        isRunning := isEngineRunning();
-        playFile(argv);
-        argc := getRealTicks();
-        DrawWorld(argc);
-        MainLoop;
-        shutdown;
-    end
-{$ENDIF}
-
 {$ENDIF}
 end.
--- a/hedgewars/options.inc	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/options.inc	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,14 +29,6 @@
 
 {$DEFINE USE_LUA_SCRIPT}
 
-{$IF DEFINED(WEBGL) AND NOT DEFINED(PAS2C)}
-{$ERROR WEBGL defined, but PAS2C isn't}
-{$ENDIF}
-
-{$IFDEF WEBGL}
-{$DEFINE GL2}
-{$ENDIF}
-
 {$IFDEF ANDROID}
     {$DEFINE MOBILE}
     {$DEFINE USE_CONTEXT_RESTORE}
@@ -72,11 +64,6 @@
     {$DEFINE SDL2}
 {$ENDIF}
 
-{$IFDEF PAS2C}
-    { $DEFINE NOCONSOLE}
-    {$DEFINE USE_SDLTHREADS}
-{$ENDIF}
-
 {$DEFINE _S:=}
 {$DEFINE _P:=}
 
--- a/hedgewars/pas2cRedo.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/pas2cRedo.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 redo;
 {This file contains functions that are re-implemented}
 {pas2c will add prefix fpcrtl_ to all these functions}
-type 
+type
     uinteger = uinteger;
     Integer = integer;
     LongInt = integer;
@@ -39,12 +39,12 @@
     char = char;
     PChar = ^char;
     PPChar = ^Pchar;
-    
+
     PByte = ^Byte;
     PLongInt = ^LongInt;
     PLongWord = ^LongWord;
     PInteger = ^Integer;
-    
+
     Handle = integer;
 
 var
@@ -83,7 +83,7 @@
     assign, rewrite, rewrite_2, reset, reset_2, flush, BlockWrite, BlockRead, close : procedure;
     FileExists, DirectoryExists, eof : function : boolean;
     ExtractFileName : function : string;
-    
+
     ParamCount : function : integer;
     ParamStr : function : string;
 
@@ -101,13 +101,13 @@
 
     random : function : integer;
     randomize : procedure;
-    
+
     Assigned : function : boolean;
 
     //EnumToStr : function : string;
 
     initParams : procedure;
-    
+
     Load_GL_VERSION_2_0 : procedure;
 
 
--- a/hedgewars/pas2cSystem.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/pas2cSystem.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 system;
-
-type 
+{This file contains functions that are external}
+type
     uinteger = uinteger;
     Integer = integer;
     LongInt = integer;
@@ -40,21 +40,21 @@
     char = char;
     PChar = ^char;
     PPChar = ^Pchar;
-    
+
     PByte = ^Byte;
     PWord = ^Word;
     PLongInt = ^LongInt;
     PLongWord = ^LongWord;
     PInteger = ^Integer;
-    
+
     Handle = integer;
 
     png_structp = pointer;
     png_size_t = integer;
 
-var 
+var
     false, true: boolean;
-    
+
     ord, Succ, Pred : function : integer;
     inc, dec, Low, High, Lo, Hi : function : integer;
 
@@ -72,7 +72,7 @@
     sizeof : function : integer;
 
     glGetString : function : pchar;
- 
+
     glBegin, glBindTexture, glBlendFunc, glClear, glClearColor,
     glColor4ub, glColorMask, glColorPointer, glDeleteTextures,
     glDisable, glDisableClientState, glDrawArrays, glEnable,
@@ -83,7 +83,7 @@
     glTexParameteri, glTranslatef, glVertex2d, glVertexPointer,
     glViewport, glext_LoadExtension, glDeleteRenderbuffersEXT,
     glDeleteFramebuffersEXT, glGenFramebuffersEXT,
-    glGenRenderbuffersEXT, glBindFramebufferEXT, 
+    glGenRenderbuffersEXT, glBindFramebufferEXT,
     glBindRenderbufferEXT, glRenderbufferStorageEXT,
     glFramebufferRenderbufferEXT, glFramebufferTexture2DEXT,
     glUniformMatrix4fv, glVertexAttribPointer, glCreateShader,
@@ -113,7 +113,7 @@
     GL_AUX_BUFFERS, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE, GL_ADD: integer;
 
     TThreadId : function : integer;
-    
+
     _strconcat, _strappend, _strprepend, _chrconcat : function : string;
     _strcompare, _strncompare, _strcomparec : function : boolean;
 
--- a/hedgewars/res/hwengine.rc	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/res/hwengine.rc	Tue Jan 21 22:38:13 2014 +0100
@@ -1,1 +1,2 @@
-MAINICON ICON "res/hwengine.ico"
\ No newline at end of file
+MAINICON ICON "res/hwengine.ico"
+
--- a/hedgewars/uAI.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uAI.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,11 +33,6 @@
     uAmmos, SysUtils, uTypes,
     uVariables, uCommands, uUtils, uDebug, uAILandMarks;
 
-{$IFDEF AI_MAINTHREAD}
-const
-    mainThreadMaxThinkTime:Integer = 1500;
-{$ENDIF}
-
 var BestActions: TActions;
     CanUseAmmo: array [TAmmoType] of boolean;
     StopThinking: boolean;
@@ -365,13 +360,8 @@
             if GoInfo.FallPix >= FallPixForBranching then
                 Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right
 
-{$IFDEF AI_MAINTHREAD}
-            if StartTicks < (SDL_GetTicks() - mainThreadMaxThinkTime) then
-                StopThinking := true;
-{$ELSE}
             if (StartTicks > GameTicks - 1500) and (not StopThinking) then
                 SDL_Delay(1000);
-{$ENDIF}
 
             end {while};
 
@@ -436,13 +426,8 @@
             or (itHedgehog = currHedgehogIndex)
             or BestActions.isWalkingToABetterPlace;
 
-            {$IFDEF AI_MAINTHREAD}
-                if StartTicks < (SDL_GetTicks() - mainThreadMaxThinkTime) then
-                    StopThinking := true;
-            {$ELSE}
-                if (StartTicks > GameTicks - 1500) and (not StopThinking) then
-                    SDL_Delay(1000);
-            {$ENDIF}
+            if (StartTicks > GameTicks - 1500) and (not StopThinking) then
+                SDL_Delay(1000);
 
         if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then
             begin
--- a/hedgewars/uAIActions.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uAIActions.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uAIAmmoTests.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uAIAmmoTests.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1241,7 +1241,7 @@
     x:= x + dx;
     dy:= dy + cGravityf;
     y:= y + dy;
-    
+
     if TestColl(trunc(x), trunc(y), 3) then
         t:= 0;
 until t = 0;
@@ -1251,7 +1251,7 @@
 
 if Level = 1 then
     valueResult:= RateExplosion(Me, EX, EY, 76, afTrackFall or afErasesLand)
-else 
+else
     valueResult:= RateExplosion(Me, EX, EY, 76);
 
 if (valueResult > 0) then
--- a/hedgewars/uAIMisc.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uAIMisc.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,12 +53,12 @@
     X, Y: LongInt;
     Radius: LongInt;
     Score: LongInt;
-	 end;
+     end;
 
 Tbonuses = record
-	      Count : Longword;
-	      ar    : array[0..Pred(MAXBONUS)] of TBonus;
-	   end;
+          Count : Longword;
+          ar    : array[0..Pred(MAXBONUS)] of TBonus;
+       end;
 
 Twalkbonuses =  record
         Count: Longword;
@@ -101,7 +101,7 @@
 var dmgMod: real = 1.0;
 
 implementation
-uses uCollisions, uVariables, uUtils, uLandTexture, uGearsUtils;
+uses uCollisions, uVariables, uUtils, uGearsUtils;
 
 var
     KnownExplosion: record
@@ -137,7 +137,7 @@
         ((Gear^.Kind = gtMine) and
             (Gear^.Health = 0) and
              (Gear^.Damage < 35))
-             )  and 
+             )  and
         (Targets.Count < 256) then
         begin
         with Targets.ar[Targets.Count] do
@@ -159,7 +159,7 @@
                     Score:= Gear^.Damage - Gear^.Health;
                     inc(f)
                     end
-                else 
+                else
                     begin
                     Score:= Gear^.Health - Gear^.Damage;
                     inc(e)
@@ -167,7 +167,7 @@
                 end
             else if Gear^.Kind = gtExplosives then
                 Score:= Gear^.Health - Gear^.Damage
-            else if Gear^.Kind = gtMine then 
+            else if Gear^.Kind = gtMine then
                 Score:= max(0,35-Gear^.Damage);
             end;
         inc(Targets.Count)
@@ -388,14 +388,14 @@
                     dmg := 1 + trunc((dY - 0.4) * 70);
                     exit(dmg)
                     end
-                else 
+                else
                     begin
                     dxdy:= abs(dX)+abs(dY);
-                    if ((Kind = gtMine) and (dxdy > 0.35)) or 
-                       ((Kind = gtExplosives) and 
+                    if ((Kind = gtMine) and (dxdy > 0.35)) or
+                       ((Kind = gtExplosives) and
                             (((State and gstTmpFlag <> 0) and (dxdy > 0.35)) or
-                             ((State and gstTmpFlag = 0) and 
-                                ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and 
+                             ((State and gstTmpFlag = 0) and
+                                ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and
                                 (abs(odX) > 0.02))) and (dxdy > 0.35)))) then
                         begin
                         dmg := trunc(dxdy * 25);
@@ -440,14 +440,14 @@
                     dmg := trunc((dY - 0.4) * 70);
                     exit(dmg);
                     end
-                else 
+                else
                     begin
                     dxdy:= abs(dX)+abs(dY);
-                    if ((Kind = gtMine) and (dxdy > 0.4)) or 
-                       ((Kind = gtExplosives) and 
+                    if ((Kind = gtMine) and (dxdy > 0.4)) or
+                       ((Kind = gtExplosives) and
                             (((State and gstTmpFlag <> 0) and (dxdy > 0.4)) or
-                             ((State and gstTmpFlag = 0) and 
-                                ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and 
+                             ((State and gstTmpFlag = 0) and
+                                ((abs(odX) > 0.15) or ((abs(odY) > 0.15) and
                                 (abs(odX) > 0.02))) and (dxdy > 0.35)))) then
                         begin
                         dmg := trunc(dxdy * 50);
@@ -524,7 +524,7 @@
                     begin
                     dX:= (0.005 * dmg + 0.01) / Density;
                     dY:= dX;
-                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and 
+                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and
                        (((abs(dY) > 0.15) and (abs(dX) < 0.02)) or
                         ((abs(dY) < 0.15) and (abs(dX) < 0.15))) then
                         dX:= 0;
@@ -611,7 +611,7 @@
                 fallDmg:= 0;
                 if (Flags and afSetSkip <> 0) then skip:= true;
                 if (not dead) and (Flags and afTrackFall <> 0) and (Score > 0) and (power < Score) then
-                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and 
+                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and
                        (((abs(dY) > 0.15) and (abs(dX) < 0.02)) or
                         ((abs(dY) < 0.15) and (abs(dX) < 0.15))) then
                         fallDmg:= trunc(TraceShoveFall(pX, pY, 0, dY, Targets.ar[i]) * dmgMod)
@@ -713,9 +713,9 @@
                     dY:= gdY * dmg / Density;
                     if dX < 0 then dX:= dX - 0.01
                     else dX:= dX + 0.01;
-                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and 
+                    if (Kind = gtExplosives) and (State and gstTmpFlag = 0) and
                        (((abs(dY) > 0.15) and (abs(dX) < 0.02)) or
-                        ((abs(dY) < 0.15) and (abs(dX) < 0.15))) then 
+                        ((abs(dY) < 0.15) and (abs(dX) < 0.15))) then
                        dX:= 0;
                     if (x and LAND_WIDTH_MASK = 0) and ((y+cHHRadius+2) and LAND_HEIGHT_MASK = 0) and
                        (Land[y+cHHRadius+2, x] and lfIndestructible <> 0) then
--- a/hedgewars/uAmmos.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uAmmos.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@
 var StoreCnt: Longword;
 
 implementation
-uses uLocale, uVariables, uCommands, uUtils, uCaptions, uDebug;
+uses uVariables, uCommands, uUtils, uCaptions, uDebug;
 
 type TAmmoCounts = array[TAmmoType] of Longword;
      TAmmoArray = array[TAmmoType] of TAmmo;
@@ -132,22 +132,22 @@
             inc(Ammoz[a].SkipTurns,10000);
     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
         ammos[a]:= AMMO_INFINITE
-        end 
-        
+        end
+
     else
         ammos[a]:= AMMO_INFINITE;
-    if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then 
+    if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
         InitialCounts[Pred(StoreCnt)][a]:= cnt
     else
         InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
     end;
-    
+
     for a:= Low(TAmmoType) to High(TAmmoType) do
         begin
         newAmmos[a]:= Ammoz[a].Ammo;
         newAmmos[a].Count:= ammos[a]
         end;
-        
+
 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos)
 end;
 
@@ -311,7 +311,7 @@
             if (AmmoType = Ammo) then
                 if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
                     exit(Count)
-                else 
+                else
                     exit(0);
         inc(ami)
     end;
@@ -482,7 +482,7 @@
 
 for a:= Low(TAmmoType) to High(TAmmoType) do
     newAmmos[a]:= Ammoz[a].Ammo;
-    
+
 for i:= 0 to Pred(StoreCnt) do
     begin
     for a:= Low(TAmmoType) to High(TAmmoType) do
@@ -499,8 +499,8 @@
 
 procedure chAddAmmoStore(var descr: shortstring);
 begin
-descr:= ''; // avoid compiler hint
-AddAmmoStore
+    descr:= ''; // avoid compiler hint
+    AddAmmoStore
 end;
 
 procedure initModule;
--- a/hedgewars/uCaptions.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uCaptions.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
- 
+
 {$INCLUDE "options.inc"}
 
 unit uCaptions;
@@ -52,7 +52,7 @@
         FreeTexture(Captions[Group].Tex);
         Captions[Group].Tex:= nil
         end;
-    
+
     if Captions[Group].Tex = nil then
         begin
         Captions[Group].Color:= Color;
--- a/hedgewars/uChat.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uChat.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uCollisions.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uCollisions.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -92,7 +92,7 @@
 if (Count > (MAXRECTSINDEX-20)) then
     begin
     t:= GearsList;
-    while (t <> nil) and (t^.Kind <> gtMine) do 
+    while (t <> nil) and (t^.Kind <> gtMine) do
         t:= t^.NextGear;
     if (t <> nil) then
         t^.State:= t^.State or gmDelete
@@ -234,7 +234,7 @@
 
     for i:= 0 to Pred(Count) do
         with cinfos[i] do
-            if  (Gear <> cGear) and 
+            if  (Gear <> cGear) and
                 ((mx > x) xor (Dir > 0)) and
                 (
                   ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
@@ -300,7 +300,7 @@
             if (Gear <> cGear) and
                ((myr > y) xor (Dir > 0)) and
                (Gear^.State and gstNotKickable = 0) and
-               (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
+               (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and
                (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
                     begin
                     with cGear^ do
@@ -327,7 +327,7 @@
 begin
 Gear^.X:= Gear^.X + ShiftX;
 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
-if withGear then 
+if withGear then
     TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir)
 else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir);
 Gear^.X:= Gear^.X - ShiftX;
@@ -394,7 +394,7 @@
   TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir)
 else
   TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir);
-  
+
 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
 end;
@@ -583,7 +583,7 @@
     isColl, bSucc: Boolean;
 begin
 
-if dirY <> 0 then 
+if dirY <> 0 then
     begin
     y:= hwRound(Gear^.Y) + Gear^.Radius * dirY;
     gx:= hwRound(Gear^.X);
--- a/hedgewars/uCommandHandlers.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uCommandHandlers.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -121,7 +121,8 @@
 
 procedure chScriptParam(var s: shortstring);
 begin
-    cScriptParam:= s;
+    ScriptSetString('ScriptParam', s);
+    ScriptCall('onParameters');
 end;
 
 procedure chCurU_p(var s: shortstring);
@@ -144,37 +145,37 @@
 
 procedure chCurD_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 CursorMovementY:= 0;
 end;
 
 procedure chCurL_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 CursorMovementX:= -1;
 end;
 
 procedure chCurL_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 CursorMovementX:= 0;
 end;
 
 procedure chCurR_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 CursorMovementX:= 1;
 end;
 
 procedure chCurR_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 CursorMovementX:= 0;
 end;
 
 procedure chLeft_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -187,7 +188,7 @@
 
 procedure chLeft_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -199,7 +200,7 @@
 
 procedure chRight_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -212,7 +213,7 @@
 
 procedure chRight_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -224,7 +225,7 @@
 
 procedure chUp_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -237,7 +238,7 @@
 
 procedure chUp_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -249,7 +250,7 @@
 
 procedure chDown_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -262,7 +263,7 @@
 
 procedure chDown_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -274,7 +275,7 @@
 
 procedure chPrecise_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -287,7 +288,7 @@
 
 procedure chPrecise_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -299,7 +300,7 @@
 
 procedure chLJump(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -312,7 +313,7 @@
 
 procedure chHJump(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -325,7 +326,7 @@
 
 procedure chAttack_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 bShowFinger:= false;
@@ -345,7 +346,7 @@
 
 procedure chAttack_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     exit;
 with CurrentHedgehog^.Gear^ do
@@ -360,7 +361,7 @@
 
 procedure chSwitch(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 if not isExternalSource then
@@ -372,10 +373,9 @@
 end;
 
 procedure chNextTurn(var s: shortstring);
-var i  : Longword;
-    gi : PGear;
+var gi: PGear;
 begin
-    s:=s; // avoid compiler hint
+    s:= s; // avoid compiler hint
 
     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
 
@@ -482,13 +482,13 @@
 
 procedure chPut(var s: shortstring);
 begin
-    s:=s; // avoid compiler hint
+    s:= s; // avoid compiler hint
     doPut(0, 0, false);
 end;
 
 procedure chCapture(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 flagMakeCapture:= true
 end;
 
@@ -539,7 +539,7 @@
 
 procedure chAmmoMenu(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH then
     bShowAmmoMenu:= true
 else
@@ -563,19 +563,19 @@
 
 procedure chVol_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 inc(cVolumeDelta, 3)
 end;
 
 procedure chVol_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 dec(cVolumeDelta, 3)
 end;
 
 procedure chFindhh(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then
     exit;
 
@@ -597,7 +597,7 @@
 
 procedure chPause(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 if gameType <> gmtNet then
     isPaused:= not isPaused
     else
@@ -639,34 +639,34 @@
 
 procedure chSpeedup_p(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 SpeedStart:= RealTicks;
 isSpeed:= true
 end;
 
 procedure chSpeedup_m(var s: shortstring);
 begin
-s:=s; // avoid compiler hint
+s:= s; // avoid compiler hint
 isSpeed:= false
 end;
 
 procedure chZoomIn(var s: shortstring);
 begin
-    s:=s; // avoid compiler hint
+    s:= s; // avoid compiler hint
     if ZoomValue < cMinZoomLevel then
         ZoomValue:= ZoomValue + cZoomDelta;
 end;
 
 procedure chZoomOut(var s: shortstring);
 begin
-    s:=s; // avoid compiler hint
+    s:= s; // avoid compiler hint
     if ZoomValue > cMaxZoomLevel then
         ZoomValue:= ZoomValue - cZoomDelta;
 end;
 
 procedure chZoomReset(var s: shortstring);
 begin
-    s:=s; // avoid compiler hint
+    s:= s; // avoid compiler hint
     ZoomValue:= cDefaultZoomLevel;
 end;
 
--- a/hedgewars/uCommands.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uCommands.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uConsole.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uConsole.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uConsts.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uConsts.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -103,8 +103,8 @@
     lfNotCurrentMask = $FF7F;  // inverse of above. frequently used
     lfObjMask        = $007F;  // lower 7 bits used for hogs
     lfNotObjMask     = $FF80;  // inverse of above.
-    // lower byte is for objects. 
-    // consists of 0-127 counted for object checkins and $80 as a bit flag for current hog. 
+    // lower byte is for objects.
+    // consists of 0-127 counted for object checkins and $80 as a bit flag for current hog.
     lfAllObjMask     = $00FF;  // lfCurrentHog or lfObjMask
 
 
@@ -302,6 +302,10 @@
 
     kSystemSoundID_Vibrate = $00000FFF;
 
+    rtnTestSuccess = $00000000;
+    rtnTestFailed  = $00000001;
+    rtnTestLuaErr  = $00000002;
+
 implementation
 
 end.
--- a/hedgewars/uCursor.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uCursor.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -11,10 +11,6 @@
 
 uses SDLh, uVariables;
 
-{$IFDEF WEBGL}
-var offsetx, offsety : Integer;
-{$ENDIF}
-
 procedure init;
 begin
     resetPosition();
@@ -27,33 +23,16 @@
 
 procedure updatePosition;
 var x, y: LongInt;
-{$IFDEF WEBGL}
-    tx, ty : LongInt;
-{$ENDIF}
 begin
     SDL_GetMouseState(@x, @y);
-
-{$IFDEF WEBGL}
-    tx := x;
-    ty := y;
-    x := x + offsetx;
-    y := y + offsety;
-{$ENDIF}
-
+    
     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
     begin
         handlePositionUpdate(x - cScreenWidth div 2, y - cScreenHeight div 2);
 
         if cHasFocus then
-            begin
-            {$IFNDEF WEBGL}
             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
-            {$ELSE}
-            offsetx := cScreenWidth div 2 - tx;
-            offsety := cScreenHeight div 2 - ty;
-            {$ENDIF}
-            end;
-        end
+    end
 end;
 
 procedure handlePositionUpdate(x, y: LongInt);
--- a/hedgewars/uDebug.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uDebug.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uFloat.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uFloat.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,6 @@
  *)
 interface
 
-{$IFDEF FPC}
 {$IFDEF ENDIAN_LITTLE}
 type hwFloat = record
     isNegative: boolean;
@@ -55,7 +54,7 @@
     1: (QWordValue : QWord);
     end;
 {$ENDIF}
-		  
+
 // Returns an hwFloat that represents the value of integer parameter i
 function int2hwFloat (const i: LongInt) : hwFloat; inline;
 function hwFloat2Float (const i: hwFloat) : extended; inline;
@@ -97,14 +96,9 @@
 function hwSign(r: hwFloat): LongInt; inline; // Returns an integer with value 1 and sign of parameter r.
 function hwSignf(r: real): LongInt; inline; // Returns an integer with value 1 and sign of parameter r.
 function isZero(const z: hwFloat): boolean; inline;
-{$IFDEF FPC}
-{$J-}
-{$ENDIF}
+
 {$WARNINGS OFF}
-
-
 // some hwFloat constants
-
 const  _1div1024: hwFloat = (isNegative: false; QWordValue:     4194304);
       _1div10000: hwFloat = (isNegative: false; QWordValue:      429496);
       _1div50000: hwFloat = (isNegative: false; QWordValue:       85899);
@@ -196,18 +190,11 @@
          cLittle: hwFloat = (isNegative: false; QWordValue:           1);
          cHHKick: hwFloat = (isNegative: false; QWordValue:    42949673);  // _0_01
 {$WARNINGS ON}
-{$ENDIF}
-
-{$IFNDEF FPC}
-type hwFloat = Extended;
-{$ENDIF}
 
 implementation
 uses uSinTable;
 
 
-{$IFDEF FPC}
-
 function int2hwFloat (const i: LongInt) : hwFloat; inline;
 begin
 int2hwFloat.isNegative:= i < 0;
@@ -222,7 +209,6 @@
     hwFloat2Float:= -hwFloat2Float;
 end;
 
-{$IFNDEF WEBGL}
 operator = (const z1, z2: hwFloat) z : boolean; inline;
 begin
     z:= (z1.isNegative = z2.isNegative) and (z1.QWordValue = z2.QWordValue);
@@ -301,194 +287,98 @@
     else
         b:= (z1.QWordValue > z2.QWordValue) <> z2.isNegative
 end;
-{$ENDIF}
-{$IFDEF WEBGL}
-(*
-    Mostly to be kind to JS as of 2012-08-27 where there is no int64/uint64.  This may change though.
-*)
-operator = (const z1, z2: hwFloat) z : boolean; inline;
-begin
-    z:= (z1.isNegative = z2.isNegative) and (z1.Frac = z2.Frac) and (z1.Round = z2.Round);
-end;
-
-operator <> (const z1, z2: hwFloat) z : boolean; inline;
-begin
-    z:= (z1.isNegative <> z2.isNegative) or (z1.Frac <> z2.Frac) or (z1.Round <> z2.Round);
-end;
-
-operator + (const z1, z2: hwFloat) z : hwFloat; inline;
-begin
-if z1.isNegative = z2.isNegative then
-    begin
-    z:= z1;
-    z.Frac:= z.Frac + z2.Frac;
-    z.Round:= z.Round + z2.Round;
-    if z.Frac<z1.Frac then inc(z.Round)
-    end
-else
-    if (z1.Round > z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac)) then
-        begin
-        z.isNegative:= z1.isNegative;
-        z.Round:= z1.Round - z2.Round;
-        z.Frac:= z1.Frac - z2.Frac;
-        if z2.Frac > z1.Frac then dec(z.Round)
-        end
-    else
-        begin
-        z.isNegative:= z2.isNegative;
-        z.Round:= z2.Round - z1.Round;
-        z.Frac:= z2.Frac-z1.Frac;
-        if z2.Frac < z1.Frac then dec(z.Round)
-        end
-end;
-
-operator - (const z1, z2: hwFloat) z : hwFloat; inline;
-begin
-if z1.isNegative = z2.isNegative then
-    if (z1.Round > z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac)) then
-        begin
-        z.isNegative:= z1.isNegative;
-        z.Round:= z1.Round - z2.Round;
-        z.Frac:= z1.Frac-z2.Frac;
-        if z2.Frac > z1.Frac then dec(z.Round)
-        end
-    else
-        begin
-        z.isNegative:= not z2.isNegative;
-        z.Round:= z2.Round - z1.Round;
-        z.Frac:= z2.Frac-z1.Frac;
-        if z2.Frac < z1.Frac then dec(z.Round)
-        end
-else
-    begin
-    z:= z1;
-    z.Frac:= z.Frac + z2.Frac;
-    z.Round:= z.Round + z2.Round;
-    if z.Frac<z1.Frac then inc(z.Round)
-    end
-end;
-
-operator < (const z1, z2: hwFloat) b : boolean; inline;
-begin
-if z1.isNegative xor z2.isNegative then
-    b:= z1.isNegative
-else
-(*  Not so sure this specialcase is a win w/ Round/Frac. have to do more tests anyway.
-    if (z1.Round = z2.Round and (z1.Frac = z2.Frac)) then
-        b:= false
-    else *)
-        b:= ((z1.Round < z2.Round) or ((z1.Round = z2.Round) and (z1.Frac < z2.Frac))) <> z1.isNegative
-end;
-
-operator > (const z1, z2: hwFloat) b : boolean; inline;
-begin
-if z1.isNegative xor z2.isNegative then
-    b:= z2.isNegative
-else
-(*
-    if z1.QWordValue = z2.QWordValue then
-        b:= false
-    else*)
-        b:= ((z1.Round > z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac))) <> z1.isNegative
-end;
-
-function isZero(const z: hwFloat): boolean; inline; 
-begin
-isZero := (z.Round = 0) and (z.Frac = 0);
-end;
-{$ENDIF}
 
 operator - (const z1: hwFloat) z : hwFloat; inline;
 begin
-z:= z1;
-z.isNegative:= not z.isNegative
+    z:= z1;
+    z.isNegative:= not z.isNegative
 end;
 
 
 operator * (const z1, z2: hwFloat) z : hwFloat; inline;
 begin
-z.isNegative:= z1.isNegative xor z2.isNegative;
-z.QWordValue:= QWord(z1.Round) * z2.Frac + QWord(z1.Frac) * z2.Round + ((QWord(z1.Frac) * z2.Frac) shr 32);
-z.Round:= z.Round + QWord(z1.Round) * z2.Round;
+    z.isNegative:= z1.isNegative xor z2.isNegative;
+    z.QWordValue:= QWord(z1.Round) * z2.Frac + QWord(z1.Frac) * z2.Round + ((QWord(z1.Frac) * z2.Frac) shr 32);
+    z.Round:= z.Round + QWord(z1.Round) * z2.Round;
 end;
 
 operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline;
 begin
-z.isNegative:= z1.isNegative xor (z2 < 0);
-z.QWordValue:= z1.QWordValue * abs(z2)
+    z.isNegative:= z1.isNegative xor (z2 < 0);
+    z.QWordValue:= z1.QWordValue * abs(z2)
 end;
 
 operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline;
 var t: QWord;
 begin
-z.isNegative:= z1.isNegative xor z2.isNegative;
-z.Round:= z1.QWordValue div z2.QWordValue;
-t:= z1.QWordValue - z2.QWordValue * z.Round;
-z.Frac:= 0;
+    z.isNegative:= z1.isNegative xor z2.isNegative;
+    z.Round:= z1.QWordValue div z2.QWordValue;
+    t:= z1.QWordValue - z2.QWordValue * z.Round;
+    z.Frac:= 0;
 
-if t <> 0 then
-    begin
-    while ((t and $FF00000000000000) = 0) and ((z2.QWordValue and $FF00000000000000) = 0) do
+    if t <> 0 then
         begin
-        t:= t shl 8;
-        z2.QWordValue:= z2.QWordValue shl 8
-        end;
+        while ((t and $FF00000000000000) = 0) and ((z2.QWordValue and $FF00000000000000) = 0) do
+            begin
+            t:= t shl 8;
+            z2.QWordValue:= z2.QWordValue shl 8
+            end;
 
-    if z2.Round > 0 then
-        inc(z.QWordValue, t div z2.Round);
-    end
+        if z2.Round > 0 then
+            inc(z.QWordValue, t div z2.Round);
+        end
 end;
 
 operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline;
 begin
-z.isNegative:= z1.isNegative xor (z2 < 0);
-z.QWordValue:= z1.QWordValue div abs(z2)
+    z.isNegative:= z1.isNegative xor (z2 < 0);
+    z.QWordValue:= z1.QWordValue div abs(z2)
 end;
 
 function cstr(const z: hwFloat): shortstring;
 var tmpstr: shortstring;
 begin
-str(z.Round, cstr);
-if z.Frac <> 0 then
-    begin
-    str(z.Frac / $100000000, tmpstr);
-    delete(tmpstr, 1, 2);
-    cstr:= cstr + '.' + copy(tmpstr, 1, 10)
-    end;
-if z.isNegative then
-    cstr:= '-' + cstr
+    str(z.Round, cstr);
+    if z.Frac <> 0 then
+        begin
+        str(z.Frac / $100000000, tmpstr);
+        delete(tmpstr, 1, 2);
+        cstr:= cstr + '.' + copy(tmpstr, 1, 10)
+        end;
+    if z.isNegative then
+        cstr:= '-' + cstr
 end;
 
 function hwRound(const t: hwFloat): LongInt;
 begin
-if t.isNegative then
-    hwRound:= -(t.Round and $7FFFFFFF)
-else
-    hwRound:= t.Round and $7FFFFFFF
+    if t.isNegative then
+        hwRound:= -(t.Round and $7FFFFFFF)
+    else
+        hwRound:= t.Round and $7FFFFFFF
 end;
 
 function hwAbs(const t: hwFloat): hwFloat;
 begin
-hwAbs:= t;
-hwAbs.isNegative:= false
+    hwAbs:= t;
+    hwAbs.isNegative:= false
 end;
 
 function hwSqr(const t: hwFloat): hwFloat; inline;
 begin
-hwSqr.isNegative:= false;
-hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32);
+    hwSqr.isNegative:= false;
+    hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32);
 end;
 
 function hwPow(const t: hwFloat;p: LongWord): hwFloat;
 begin
-hwPow:= t;
-if p mod 2 = 0 then hwPow.isNegative:= false;
+    hwPow:= t;
+    if p mod 2 = 0 then hwPow.isNegative:= false;
 
-while p > 0 do
-    begin
-    hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32);
-    dec(p)
-    end
+    while p > 0 do
+        begin
+        hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32);
+        dec(p)
+        end
 end;
 
 function hwSqrt1(const t: hwFloat): hwFloat;
@@ -498,65 +388,67 @@
 var l, r: QWord;
     c: hwFloat;
 begin
-hwSqrt1.isNegative:= false;
+    hwSqrt1.isNegative:= false;
 
-if t.Round = 0 then
-    begin
-    l:= t.QWordValue;
-    r:= $100000000
-    end
-else
-    begin
-    if t.QWordValue > $FFFFFFFFFFFF then // t.Round > 65535.9999
+    if t.Round = 0 then
+        begin
+        l:= t.QWordValue;
+        r:= $100000000
+        end
+    else
         begin
-        l:= $10000000000; // 256
-        r:= $FFFFFFFFFFFF; // 65535.9999
-        end else
-        if t.QWordValue >= rThreshold then
+        if t.QWordValue > $FFFFFFFFFFFF then // t.Round > 65535.9999
             begin
-            l:= lThreshold;
-            r:= $10000000000; // 256
-            end else
-            begin
-            l:= $100000000;
-            r:= lThreshold;
-            end;
+            l:= $10000000000; // 256
+            r:= $FFFFFFFFFFFF; // 65535.9999
+            end
+        else
+            if t.QWordValue >= rThreshold then
+                begin
+                l:= lThreshold;
+                r:= $10000000000; // 256
+                end
+            else
+                begin
+                l:= $100000000;
+                r:= lThreshold;
+                end;
     end;
 
-repeat
-    c.QWordValue:= (l + r) shr 1;
-    if hwSqr(c).QWordValue > t.QWordValue then
-        r:= c.QWordValue
-    else
-        l:= c.QWordValue
-until r - l <= 1;
+    repeat
+        c.QWordValue:= (l + r) shr 1;
+        if hwSqr(c).QWordValue > t.QWordValue then
+            r:= c.QWordValue
+        else
+            l:= c.QWordValue
+    until r - l <= 1;
 
-hwSqrt1.QWordValue:= l
+    hwSqrt1.QWordValue:= l
 end;
 
 function hwSqrt(const x: hwFloat): hwFloat;
 var r, t, s, q: QWord;
     i: integer;
 begin
-hwSqrt.isNegative:= false;
+    hwSqrt.isNegative:= false;
 
-t:= $4000000000000000;
-r:= 0;
-q:= x.QWordValue;
+    t:= $4000000000000000;
+    r:= 0;
+    q:= x.QWordValue;
 
-for i:= 0 to 31 do
-    begin
-    s:= r + t;
-    r:= r shr 1;
-    if s <= q then
+    for i:= 0 to 31 do
         begin
-        dec(q, s);
-        inc(r, t);
+        s:= r + t;
+        r:= r shr 1;
+        if s <= q then
+            begin
+            dec(q, s);
+            inc(r, t);
+            end;
+        t:= t shr 2;
         end;
-    t:= t shr 2;
-    end;
 
-hwSqrt.QWordValue:= r shl 16
+    hwSqrt.QWordValue:= r shl 16
 end;
 
 
@@ -564,25 +456,26 @@
 function Distance(const dx, dy: hwFloat): hwFloat;
 var r: QWord;
 begin
-r:= dx.QWordValue or dy.QWordValue;
+    r:= dx.QWordValue or dy.QWordValue;
 
-if r < $10000 then
-    begin
-    Distance.QWordValue:= r;
-    Distance.isNegative:= false
-    end else
-    Distance:= hwSqrt(hwSqr(dx) + hwSqr(dy))
+    if r < $10000 then
+        begin
+        Distance.QWordValue:= r;
+        Distance.isNegative:= false
+        end
+    else
+        Distance:= hwSqrt(hwSqr(dx) + hwSqr(dy))
 end;
 
 function DistanceI(const dx, dy: LongInt): hwFloat;
 begin
-DistanceI:= hwSqrt(int2hwFloat(sqr(dx) + sqr(dy)))
+    DistanceI:= hwSqrt(int2hwFloat(sqr(dx) + sqr(dy)))
 end;
 
 function SignAs(const num, signum: hwFloat): hwFloat;
 begin
-SignAs.QWordValue:= num.QWordValue;
-SignAs.isNegative:= signum.isNegative
+    SignAs.QWordValue:= num.QWordValue;
+    SignAs.isNegative:= signum.isNegative
 end;
 
 function hwSign(r: hwFloat): LongInt;
@@ -655,6 +548,4 @@
     vector2Angle:= c
 end;
 
-{$ENDIF}
-
 end.
--- a/hedgewars/uGame.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGame.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -116,7 +116,8 @@
                         AddVisualGear(0, 0, vgtTeamHealthSorter);
                         AddVisualGear(0, 0, vgtSmoothWindBar);
                         {$IFDEF IPHONEOS}InitIPC;{$ENDIF}
-                        {$IFNDEF PAS2C}with mobileRecord do
+                        {$IFNDEF PAS2C}
+                        with mobileRecord do
                             if SaveLoadingEnded <> nil then
                                 SaveLoadingEnded();
                         {$ENDIF}
--- a/hedgewars/uGears.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGears.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,11 +46,12 @@
 procedure AddMiscGears;
 procedure AssignHHCoords;
 function  GearByUID(uid : Longword) : PGear;
+
 implementation
 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
     {$IFDEF USE_TOUCH_INTERFACE}uTouch,{$ENDIF}
     uLocale, uAmmos, uStats, uVisualGears, uScript, uVariables,
-    uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture,
+    uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug,
     uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlersRope
     , uVisualGearsList, uGearsHandlersMess, uAI;
 
@@ -126,7 +127,7 @@
             tmp:= 0;
             if Gear^.Hedgehog^.Effects[hePoisoned] <> 0 then
                 begin
-                inc(tmp, ModifyDamage(5, Gear));
+                inc(tmp, ModifyDamage(Gear^.Hedgehog^.Effects[hePoisoned], Gear));
                 if (GameFlags and gfResetHealth) <> 0 then
                     dec(Gear^.Hedgehog^.InitialHealth)  // does not need a minimum check since <= 1 basically disables it
                 end;
@@ -144,7 +145,7 @@
                     if (team^.Hedgehogs[i].Gear <> nil) and (not team^.Hedgehogs[i].King)
                     and (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) then
                         flag:= true;
-                if (not flag) then
+                if not flag then
                     begin
                     inc(tmp, 5);
                     if (GameFlags and gfResetHealth) <> 0 then
@@ -208,7 +209,7 @@
             RemoveGearFromList(curHandledGear);
             // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block
             if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
-            curHandledGear^.Message:= (curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList)))
+            curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))
             end;
         if curHandledGear^.Active then
             begin
@@ -323,7 +324,7 @@
                 StopMusic //No SDMusic for now
                     //ChangeMusic(SDMusic)
                     end
-                else if ((TotalRounds < cSuddenDTurns) and (not isInMultiShoot)) then
+                else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
                     begin
                     i:= cSuddenDTurns - TotalRounds;
                     s:= inttostr(i);
@@ -346,7 +347,7 @@
             end;
     stSpawn:
         begin
-        if (not isInMultiShoot) then
+        if not isInMultiShoot then
             SpawnBoxOfSmth;
         inc(step)
         end;
@@ -396,7 +397,7 @@
                 CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstHHChooseTarget;
                 isCursorVisible := true
                 end;
-            CurrentHedgehog^.Gear^.State:= (CurrentHedgehog^.Gear^.State and (not gstAttacked));
+            CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacked);
             end;
         if delay2 = 0 then
             begin
@@ -424,7 +425,7 @@
     if CurrentHedgehog^.Gear <> nil then
         if (((CurrentHedgehog^.Gear^.State and gstAttacking) = 0)
             or (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerWhileAttacking <> 0))
-            and (not(isInMultiShoot and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerInMultiShoot) <> 0))) then
+            and not(isInMultiShoot and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_DoesntStopTimerInMultiShoot) <> 0)) then
             //(CurrentHedgehog^.CurAmmoType in [amShotgun, amDEagle, amSniperRifle])
                 begin
                 if (TurnTimeLeft = 5000)
@@ -566,7 +567,6 @@
 var p,i,j,rx, ry: Longword;
     rdx, rdy: hwFloat;
     Gear: PGear;
-    temp: Longword;
 begin
 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
 
@@ -627,9 +627,9 @@
 if (not hasBorder) and cSnow then
     for i:= vobCount * Longword(max(LAND_WIDTH,4096)) div 2048 downto 1 do
         begin
-        ry:= LAND_HEIGHT + LongInt(GetRandom(750)) - 1300;
-        rx:= LongInt(GetRandom(snowRight - snowLeft)) + snowLeft;
-        AddGear(rx, ry, gtFlake, 0, _0, _0, 0);
+        rx:=GetRandom(snowRight - snowLeft);
+        ry:=GetRandom(750);
+        AddGear(rx + snowLeft, LAND_HEIGHT + ry - 1300, gtFlake, 0, _0, _0, 0)
         end
 end;
 
@@ -705,7 +705,7 @@
 while t <> nil do
     begin
     if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then
-        if (not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2)) then
+        if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then
             begin
             ApplyDamage(t, 5);
             t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02;
@@ -819,7 +819,7 @@
 procedure chSkip(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
-if (not isExternalSource) then
+if not isExternalSource then
     SendIPC(_S',');
 uStats.Skipped;
 skipFlag:= true
--- a/hedgewars/uGearsHandlers.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsHandlers.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
 
 uses uTypes;
 
-procedure cakeStep(Gear: PGear);
+function cakeStep(Gear: PGear): boolean;
 
 implementation
 
@@ -38,15 +38,17 @@
 
 procedure PrevAngle(Gear: PGear; dA: LongInt); inline;
 begin
+    inc(Gear^.WDTimer);
     Gear^.Angle := (LongInt(Gear^.Angle) - dA) and 3
 end;
 
 procedure NextAngle(Gear: PGear; dA: LongInt); inline;
 begin
+    inc(Gear^.WDTimer);
     Gear^.Angle := (LongInt(Gear^.Angle) + dA) and 3
 end;
 
-procedure cakeStep(Gear: PGear);
+function cakeStep(Gear: PGear): boolean;
 var
     xx, yy, xxn, yyn: LongInt;
     dA: LongInt;
@@ -60,30 +62,40 @@
     if (xx = 0) then
         if TestCollisionYwithGear(Gear, yy) <> 0 then
             PrevAngle(Gear, dA)
-    else
-        begin
-        Gear^.Tag := 0;
-        Gear^.Y := Gear^.Y + int2hwFloat(yy);
-        if TestCollisionXwithGear(Gear, xxn) = 0 then
+        else
             begin
-            Gear^.X := Gear^.X + int2hwFloat(xxn);
-            NextAngle(Gear, dA)
+            Gear^.Tag := 0;
+
+            if TestCollisionXwithGear(Gear, xxn) <> 0 then
+                Gear^.WDTimer:= 0;
+
+            Gear^.Y := Gear^.Y + int2hwFloat(yy);
+            if TestCollisionXwithGear(Gear, xxn) = 0 then
+                begin
+                Gear^.X := Gear^.X + int2hwFloat(xxn);
+                NextAngle(Gear, dA)
+                end
             end;
-        end;
 
     if (yy = 0) then
         if TestCollisionXwithGear(Gear, xx) <> 0 then
             PrevAngle(Gear, dA)
-    else
-        begin
-        Gear^.Tag := 0;
-        Gear^.X := Gear^.X + int2hwFloat(xx);
-        if TestCollisionYwithGear(Gear, yyn) = 0 then
+        else
             begin
-            Gear^.Y := Gear^.Y + int2hwFloat(yyn);
-            NextAngle(Gear, dA)
+            Gear^.Tag := 0;
+
+            if TestCollisionYwithGear(Gear, yyn) <> 0 then
+                Gear^.WDTimer:= 0;
+
+            Gear^.X := Gear^.X + int2hwFloat(xx);
+            if TestCollisionYwithGear(Gear, yyn) = 0 then
+                begin
+                Gear^.Y := Gear^.Y + int2hwFloat(yyn);
+                NextAngle(Gear, dA)
+                end
             end;
-        end;
+
+    cakeStep:= Gear^.WDTimer < 4
 end;
 
 end.
--- a/hedgewars/uGearsHandlersMess.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
  *            should NOT occur!
  *            Use safe functions and data types! (e.g. GetRandom() and hwFloat)
  *)
- 
+
  {$INCLUDE "options.inc"}
 
 unit uGearsHandlersMess;
@@ -208,7 +208,7 @@
         if (gi^.Kind = gtHedgehog) then
             begin
             d := r - hwRound(Distance(gi^.X - x, gi^.Y - y));
-            if (d > 1) and ((gi^.Hedgehog^.Effects[heInvulnerable] = 0)) and (GetRandom(2) = 0) then
+            if (d > 1) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) and (GetRandom(2) = 0) then
                 begin
                 if (CurrentHedgehog^.Gear = gi) then
                     PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack)
@@ -296,9 +296,9 @@
         end;
 
     // clip velocity at 2 - over 1 per pixel, but really shouldn't cause many actual problems.
-    if Gear^.dX.Round > 2 then
+    if Gear^.dX.Round > 1 then
         Gear^.dX.QWordValue:= 8589934592;
-    if Gear^.dY.Round > 2 then
+    if Gear^.dY.Round > 1 then
         Gear^.dY.QWordValue:= 8589934592;
 
     if (Gear^.State and gstSubmersible <> 0) and (gY > cWaterLine) then
@@ -394,7 +394,7 @@
         if xland <> 0 then collH := -hwSign(Gear^.dX)
         end;
     //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then
-    if (collV <> 0) and (collH <> 0) and 
+    if (collV <> 0) and (collH <> 0) and
        (((Gear^.AdvBounce=1) and ((collV=-1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)))) then
  //or ((xland or land) and lfBouncy <> 0)) then
         begin
@@ -436,7 +436,7 @@
 
     if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then
         Gear^.State := Gear^.State or gstCollision;
-    
+
     if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and
        ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then
         begin
@@ -760,7 +760,7 @@
     yy:= hwRound(Gear^.Y);
     if draw and (WorldEdge = weWrap) and ((xx < LongInt(leftX) + 3) or (xx > LongInt(rightX) - 3)) then
         begin
-        if xx < LongInt(leftX) + 3 then 
+        if xx < LongInt(leftX) + 3 then
              xx:= rightX-3
         else xx:= leftX+3;
         Gear^.X:= int2hwFloat(xx)
@@ -1772,7 +1772,7 @@
                 end
             end
     else // gsttmpFlag = 0
-        if ((GameFlags and gfInfAttack = 0) and ((TurnTimeLeft = 0) or (Gear^.Hedgehog^.Gear = nil))) 
+        if ((GameFlags and gfInfAttack = 0) and ((TurnTimeLeft = 0) or (Gear^.Hedgehog^.Gear = nil)))
         or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) then
             Gear^.State := Gear^.State or gsttmpFlag;
 end;
@@ -2163,7 +2163,7 @@
             exit
             end
         end
-    else 
+    else
         begin
         if (Gear^.Timer = 1) and (GameTicks and $3 = 0) then
             begin
@@ -2504,7 +2504,7 @@
     if Gear^.AmmoType = amRubber then LandFlags:= lfBouncy
     else if cIce then LandFlags:= lfIce;
 
-    if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or 
+    if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or
             (
             (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and
             (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256)
@@ -2907,7 +2907,7 @@
                     dmg:= dmgBase - max(hwRound(Distance(tdX, tdY)),gi^.Radius);
                 if (dmg > 1) then dmg:= ModifyDamage(min(dmg div 2, cakeDmg), gi);
                 if (dmg > 1) then
-                    if (CurrentHedgehog^.Gear = gi) and ((gi^.Hedgehog^.Effects[heInvulnerable] = 0)) then
+                    if (CurrentHedgehog^.Gear = gi) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) then
                         gi^.State := gi^.State or gstLoser
                     else
                         gi^.State := gi^.State or gstWinner;
@@ -2945,7 +2945,7 @@
         exit
         end;
 
-    cakeStep(Gear);
+    if not cakeStep(Gear) then Gear^.doStep:= @doStepCakeFall;
 
     if Gear^.Tag = 0 then
         begin
@@ -4830,7 +4830,7 @@
         if (tmp^.Kind = gtHedgehog) or (tmp^.Kind = gtMine) or (tmp^.Kind = gtExplosives) then
             begin
             //tmp^.State:= tmp^.State or gstFlatened;
-            if (tmp^.Hedgehog^.Effects[heInvulnerable] = 0) then
+            if (tmp^.Kind <> gtHedgehog) or (tmp^.Hedgehog^.Effects[heInvulnerable] = 0) then
                 ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown);
             //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
             tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0);
@@ -5384,7 +5384,7 @@
         Gear^.SoundChannel:= -1;
         if GameTicks mod 40 = 0 then dec(Gear^.Health)
         end
-    else 
+    else
         begin
         if Gear^.SoundChannel = -1 then
             Gear^.SoundChannel := LoopSound(sndIceBeam);
@@ -5491,14 +5491,14 @@
                     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
                     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
                     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
-                    
+
                     // Freeze nearby mines/explosives/cases too
                     iter := GearsList;
                     while iter <> nil do
                         begin
                         if (iter^.State and gstFrozen = 0) and
-                           ((iter^.Kind = gtExplosives) or (iter^.Kind = gtCase) or (iter^.Kind = gtMine)) and 
-                           (abs(LongInt(iter^.X.Round) - target.x) + abs(LongInt(iter^.Y.Round) - target.y) + 2 < 2 * iceRadius) 
+                           ((iter^.Kind = gtExplosives) or (iter^.Kind = gtCase) or (iter^.Kind = gtMine)) and
+                           (abs(LongInt(iter^.X.Round) - target.x) + abs(LongInt(iter^.Y.Round) - target.y) + 2 < 2 * iceRadius)
                            and (Distance(iter^.X - int2hwFloat(target.x), iter^.Y - int2hwFloat(target.y)) < int2hwFloat(iceRadius * 2)) then
                             begin
                             for t:= 0 to 5 do
--- a/hedgewars/uGearsHandlersRope.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uGearsHedgehog.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
 
 unit uGearsHedgehog;
 interface
-uses uTypes, uGearsHandlersMess; 
+uses uTypes, uGearsHandlersMess;
 
 procedure doStepHedgehog(Gear: PGear);
 procedure AfterAttack;
@@ -126,7 +126,7 @@
             LoadHedgehogHat(HHGear^.Hedgehog^, Hat);
         end;
     // Try again in the next slot
-    if (CurAmmoType = prevAmmo) and (slot < cMaxSlotIndex) then 
+    if (CurAmmoType = prevAmmo) and (slot < cMaxSlotIndex) then
         begin
         inc(slot);
         HHGear^.MsgParam:= slot;
@@ -416,7 +416,7 @@
                        amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 0);
                        amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0);
             end;
-            if altUse and (newGear <> nil) and 
+            if altUse and (newGear <> nil) and
                ((CurAmmoGear = nil) or (CurAmmoGear^.AmmoType <> amJetpack) or (Gear^.Message and gmPrecise = 0)) then
                begin
                newGear^.dX:= newDx / newGear^.Density;
@@ -830,7 +830,7 @@
 var da: LongWord;
 begin
 with HHGear^.Hedgehog^ do
-    if (((CurAmmoType = amRope) or ((CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amRope))) and 
+    if (((CurAmmoType = amRope) or ((CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amRope))) and
             ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving))
     or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then
         da:= 2
@@ -880,7 +880,7 @@
         Gear^.State:= Gear^.State and (not gstCollision)
         end;
     Gear^.State:= Gear^.State or gstMoving;
-    if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
+    if (Gear^.State and gstHHDriven <> 0) and
        (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
         begin
         // TODO: why so aggressive at setting FollowGear when falling?
@@ -903,8 +903,8 @@
 else
     begin
     land:= TestCollisionYwithGear(Gear, 1);
-    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) 
-    and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0)) 
+    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0)
+    and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0))
     and ((Gear^.State and gstHHJumping) <> 0) then
         SetLittle(Gear^.dX);
 
@@ -1348,7 +1348,7 @@
 tX:= Gear^.X;
 if WorldWrap(Gear) then
     begin
-    if (WorldEdge <> weBounce) and (Gear = CurrentHedgehog^.Gear) and 
+    if (WorldEdge <> weBounce) and (Gear = CurrentHedgehog^.Gear) and
        (CurAmmoGear <> nil) and (CurAmmoGear^.Kind =gtRope) and (CurAmmoGear^.Elasticity <> _0) then
        CurAmmoGear^.PortalCounter:= 1;
     if (WorldEdge = weWrap) and ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0))  then
--- a/hedgewars/uGearsList.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsList.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uGearsRender.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsRender.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 uses uTypes, uConsts, GLunit, uFloat, SDLh;
 
 type
-   Tar         = record
+   Tar = record
             X, Y: hwFloat;
             dLen: hwFloat;
             b : boolean;
@@ -95,7 +95,7 @@
     if (X1 = X2) and (Y1 = Y2) then
         begin
         //OutError('WARNING: zero length rope line!', false);
-    DrawRopeLine := 0;
+        DrawRopeLine:= 0;
         exit
         end;
     eX:= 0;
@@ -156,7 +156,7 @@
                 DrawSprite(sprRopeNode, x - 2, y - 2, 0)
             end
     end;
-DrawRopeLine:= roplen;
+    DrawRopeLine:= roplen;
 end;
 
 procedure DrawRope(Gear: PGear);
@@ -942,8 +942,28 @@
                 DrawTextureCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex);
 
             if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
-                DrawSprite(sprFinger, ox - 16, oy - 64,
-                            GameTicks div 32 mod 16);
+                begin
+                ty := oy - 32;
+                // move finger higher up if tags are above hog
+                if (cTagsMask and htTeamName) <> 0 then
+                    ty := ty - Team^.NameTagTex^.h - 2;
+                if (cTagsMask and htName) <> 0 then
+                    ty := ty - NameTagTex^.h - 2;
+                if (cTagsMask and htHealth) <> 0 then
+                    ty := ty - HealthTagTex^.h - 2;
+                tx := ox;
+                tx := round(max(((-cScreenWidth + 16) / zoom) + SpritesData[sprFinger].Width div 2, min(((cScreenWidth - 16) / zoom) - SpritesData[sprFinger].Width div 2, tx)));
+                ty := round(max(cScreenHeight div 2 - ((cScreenHeight - 16) / (zoom)) + SpritesData[sprFinger].Height div 2, min(cScreenHeight div 2 - ((-cScreenHeight + SpritesData[sprFinger].Height) / (zoom)) - SpritesData[sprFinger].Width div 2 - 96, ty)));
+                t := tx-ox;
+                if t <> 0 then
+                    dAngle := radtodeg(-arctan2(-(ty-oy),t)) + 90
+                else if ty > oy then
+                    dAngle := 180
+                else
+                    dAngle := 0;
+                DrawSpriteRotatedF(sprFinger, tx, ty, GameTicks div 32 mod 16, 1, dAngle);
+                end;
+
 
             if (Gear^.State and gstDrowning) = 0 then
                 if (Gear^.State and gstHHThinking) <> 0 then
--- a/hedgewars/uGearsUtils.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uGearsUtils.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -64,7 +64,7 @@
 implementation
 uses uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc,
     uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore,
-    uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, 
+    uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug,
     uGearsList, Math, uVisualGearsList, uGearsHandlersMess,
     uGearsHedgehog;
 
@@ -135,7 +135,7 @@
                             //AddFileLog('Damage: ' + inttostr(dmg));
                             if (Mask and EXPLNoDamage) = 0 then
                                 begin
-                                if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
+                                if (Gear^.Kind <> gtHedgehog) or (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then
                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
                                 else
                                     Gear^.State:= Gear^.State or gstWinner;
@@ -148,13 +148,13 @@
 
                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
                                 if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision);
-                                if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
+                                if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then
                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
                                 Gear^.Active:= true;
                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
                                 end;
                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) and (Gear^.State and gstHHDeath = 0) then
-                                Gear^.Hedgehog^.Effects[hePoisoned] := 1;
+                                Gear^.Hedgehog^.Effects[hePoisoned] := 5;
                             end;
 
                         end;
@@ -199,7 +199,8 @@
 i:= _1;
 if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then
     i:= _1_5;
-if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then
+if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog <> nil) and
+   (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then
     ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_5 * _0_01)
 else
     ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01)
@@ -250,7 +251,7 @@
                         end;
                     end
                 end;
-        if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and 
+        if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and
            (CurrentHedgehog^.Effects[heInvulnerable] = 0) then
             begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
             inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
@@ -301,7 +302,7 @@
 end;
 
 procedure CheckHHDamage(Gear: PGear);
-var 
+var
     dmg: LongInt;
     i: LongWord;
     particle: PVisualGear;
@@ -357,7 +358,7 @@
 end;
 
 function CheckGearDrowning(var Gear: PGear): boolean;
-var 
+var
     skipSpeed, skipAngle, skipDecay: hwFloat;
     i, maxDrops, X, Y: LongInt;
     vdX, vdY: real;
@@ -388,7 +389,7 @@
         vdX:= hwFloat2Float(Gear^.dX);
         vdY:= hwFloat2Float(Gear^.dY);
         // this could perhaps be a tiny bit higher.
-        if  (cWaterLine + 64 + Gear^.Radius > Y) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) 
+        if  (cWaterLine + 64 + Gear^.Radius > Y) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed)
         and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then
             begin
             Gear^.dY.isNegative := true;
@@ -424,9 +425,9 @@
                     else
                         Gear^.doStep := @doStepDrowningGear;
                         if Gear^.Kind = gtFlake then
-                            exit // skip splashes 
+                            exit // skip splashes
                 end
-            else if (Y > cWaterLine + cVisibleWater*4) and 
+            else if (Y > cWaterLine + cVisibleWater*4) and
                     ((Gear <> CurrentHedgehog^.Gear) or (CurAmmoGear = nil) or (CurAmmoGear^.State and gstSubmersible = 0)) then
                 Gear^.doStep:= @doStepDrowningGear;
             if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius))
@@ -595,7 +596,7 @@
 ignoreNearObjects:= false; // try not skipping proximity at first
 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
 tryAgain:= true;
-if WorldEdge <> weNone then 
+if WorldEdge <> weNone then
     begin
     Left:= max(Left, LongInt(leftX) + Gear^.Radius);
     Right:= min(Right,rightX-Gear^.Radius)
@@ -615,7 +616,7 @@
                 repeat
                     inc(y, 2);
                 until (y >= cWaterLine) or
-                        ((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) or 
+                        ((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) or
                         (ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) = 0));
 
                 sy:= y;
@@ -623,8 +624,8 @@
                 repeat
                     inc(y);
                 until (y >= cWaterLine) or
-                        ((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or 
-                        (ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0)); 
+                        ((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or
+                        (ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0));
 
                 if (y - sy > Gear^.Radius * 2)
                     and (((Gear^.Kind = gtExplosives)
@@ -649,15 +650,15 @@
                 end;
 
             if cnt > 0 then
-        begin
-           temp := ar[GetRandom(cnt)];
-               with temp do
+                begin
+                temp := ar[GetRandom(cnt)];
+                with temp do
                     begin
                     ar2[cnt2].x:= x;
                     ar2[cnt2].y:= y;
                     inc(cnt2)
-            end
-           end
+                    end
+                end
         until (x + Delta > Right);
 
         dec(Delta, 60)
@@ -831,7 +832,7 @@
                         end;
                     if dmg > 0 then
                         begin
-                        if t^.Hedgehog^.Effects[heInvulnerable] = 0 then
+                        if (Gear^.Kind <> gtHedgehog) or (t^.Hedgehog^.Effects[heInvulnerable] = 0) then
                             ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
                         else
                             Gear^.State:= Gear^.State or gstWinner;
@@ -894,14 +895,14 @@
     begin
     dec(i);
     Gear:= t^.ar[i];
-    if ((Ammo^.Kind = gtFlame) or (Ammo^.Kind = gtBlowTorch)) and 
+    if ((Ammo^.Kind = gtFlame) or (Ammo^.Kind = gtBlowTorch)) and
        (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heFrozen] > 255) then
         Gear^.Hedgehog^.Effects[heFrozen]:= max(255,Gear^.Hedgehog^.Effects[heFrozen]-10000);
     tmpDmg:= ModifyDamage(Damage, Gear);
     if (Gear^.State and gstNoDamage) = 0 then
         begin
 
-        if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then 
+        if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then
             begin
             VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit);
             if VGear <> nil then
@@ -927,7 +928,7 @@
                 Ammo^.Timer:= 0;
                 exit;
                 end;
-            if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
+            if (Gear^.Kind <> gtHedgehog) or (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then
                 begin
                 if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then
                     for j:= 1 to max(1,min(3,tmpDmg div 5)) do
@@ -952,7 +953,7 @@
                 end
             else
                 Gear^.State:= Gear^.State or gstWinner;
-            if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then 
+            if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then
                 begin
                 if (Ammo^.Hedgehog^.Gear <> nil) then
                     Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable);
@@ -1063,9 +1064,9 @@
     s:= 0;
     SetLength(GearsNearArray, s);
     t := GearsList;
-    while t <> nil do 
+    while t <> nil do
         begin
-        if (t^.Kind = Kind) 
+        if (t^.Kind = Kind)
             and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then
             begin
             inc(s);
@@ -1248,7 +1249,7 @@
             Gear^.dX.isNegative:= false;
             Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius)
             end
-        else 
+        else
             begin
             RightImpactTimer:= 333;
             Gear^.dX.isNegative:= true;
@@ -1276,7 +1277,7 @@
 * Window in the sky (Gear moved high into the sky, Y is used to determine X) [unfortunately, not a safe thing to do. shame, I thought aerial bombardment would be kinda neat
 This one would be really easy to freeze game unless it was flagged unfortunately.
 
-    else 
+    else
         begin
         Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight;
         Gear^.Y:= -_2048-_256-_256;
--- a/hedgewars/uIO.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uIO.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
 
 unit uIO;
 interface
-uses SDLh, uTypes, uMisc;
+uses SDLh, uTypes;
 
 procedure initModule;
 procedure freeModule;
@@ -181,7 +181,6 @@
     ss : shortstring = '';
     i  : LongInt;
     s  : shortstring;
-   t, tt   : string;
 begin
 
 // set RDNLY on file open
@@ -202,7 +201,7 @@
         while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
             begin
             ParseIPCCommand(copy(ss, 2, byte(ss[1])));
-           Delete(ss, 1, Succ(byte(ss[1])));
+            Delete(ss, 1, Succ(byte(ss[1])));
             end
         end
 until i = 0;
@@ -246,18 +245,18 @@
         s[0]:= #251;
 
     SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]);
-    
+
     AddFileLog('[IPC out] '+ sanitizeCharForLog(s[1]));
     inc(s[0], 2);
-    
+
     if isSyncedCommand(s[1]) then
         begin
         if sendBuffer.count + byte(s[0]) >= cSendBufferSize then
             flushBuffer();
-            
+
         Move(s, sendBuffer.buf[sendBuffer.count], byte(s[0]) + 1);
         inc(sendBuffer.count, byte(s[0]) + 1);
-        
+
         if (s[1] = 'N') or (s[1] = '#') then
             flushBuffer();
         end else
@@ -306,8 +305,8 @@
     begin
     if sendBuffer.count = 0 then
         SendIPC(_S'+');
-        
-     flushBuffer()    
+
+     flushBuffer()
     end
 end;
 
--- a/hedgewars/uInputHandler.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uInputHandler.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@
 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
 
 implementation
-uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug, uPhysFSLayer;
+uses uConsole, uCommands, uVariables, uConsts, uUtils, uDebug, uPhysFSLayer;
 
 const
     LSHIFT = $0200;
@@ -100,7 +100,7 @@
 end;
 *)
 procedure MaskModifier(Modifier: shortstring; var code: LongInt);
-var mod_ : shortstring;
+var mod_ : shortstring = '';
     ModifierCount, i: LongInt;
 begin
 if Modifier = '' then exit;
@@ -175,7 +175,7 @@
             LocalMessage:= LocalMessage or gmSwitch
         else if CurrentBinds[code] = '+precise' then
             LocalMessage:= LocalMessage or gmPrecise;
-            
+
         ParseCommand(CurrentBinds[code], Trusted);
         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
             ParseCommand('gencmd R', true)
@@ -486,16 +486,17 @@
             i:= 1;
             while (i <= length(l)) and (l[i] <> '=') do
                 begin
-                if l[i] <> '%' then
-                    begin
-                    p:= p + l[i];
-                    inc(i)
-                    end else
+                if l[i] = '%' then
                     begin
                     l[i]:= '$';
                     val(copy(l, i, 3), b);
                     p:= p + char(b);
                     inc(i, 3)
+                    end
+                else
+                    begin
+                    p:= p + l[i];
+                    inc(i)
                     end;
                 end;
 
@@ -504,6 +505,11 @@
                 l:= copy(l, i + 1, length(l) - i);
                 if l <> 'default' then
                     begin
+                    if (length(l) = 2) and (l[1] = '\') then
+                        l:= l[1]
+                    else if (l[1] = '"') and (l[length(l)] = '"') then
+                        l:= copy(l, 2, length(l) - 2);
+
                     p:= cmd + ' ' + l + ' ' + p;
                     ParseCommand(p, true)
                     end
@@ -511,7 +517,7 @@
             end;
 
         pfsClose(f)
-        end 
+        end
         else
             AddFileLog('[BINDS] file not found');
 end;
@@ -541,7 +547,7 @@
 if b = 0 then
     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
 else
-    begin 
+    begin
     // add bind: first check if this cmd is already bound, and remove old bind
     i:= cKbdMaxIndex;
     repeat
--- a/hedgewars/uLand.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLand.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@
 
 procedure ResizeLand(width, height: LongWord);
 var potW, potH: LongInt;
-begin
+begin 
 potW:= toPowerOf2(width);
 potH:= toPowerOf2(height);
 if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then
@@ -326,7 +326,6 @@
     rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
     topY:= LAND_HEIGHT - playHeight;
 
-
     // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ?
     if (cTemplateFilter = 4)
     or (Template.canInvert and (getrandom(2) = 0))
@@ -442,7 +441,7 @@
     
     for x:= leftX+2 to rightX-2 do
         for y:= topY+2 to LAND_HEIGHT-3 do
-            if (Land[y, x] = 0) and
+            if (Land[y, x] = 0) and 
                (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or
                ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then
             begin
@@ -450,16 +449,16 @@
                     begin
                     if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y, x-1]
-
+                        
                     else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y, x+1]
-
+                        
                     else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y-1, x]
-
+                        
                     else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y+1, x];
-
+                        
                     if (((LandPixels[y,x] and AMask) shr AShift) > 10) then
                         LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift)
                     end;
@@ -474,25 +473,25 @@
                     ((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or
                     ((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or
                     ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then
-
+                    
                 begin
-
+                
                 if (cReducedQuality and rqBlurryLand) = 0 then
-
+                
                     begin
-
+                    
                     if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y, x-1]
-
+                        
                     else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y, x+1]
-
+                        
                     else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y+1, x]
-
+                        
                     else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then
                         LandPixels[y, x]:= LandPixels[y-1, x];
-
+                        
                     if (((LandPixels[y,x] and AMask) shr AShift) > 10) then
                         LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift)
                     end;
@@ -638,11 +637,9 @@
     LAND_HEIGHT - tmpsurf^.h,
     tmpsurf^.w,
     tmpsurf);
-
 SDL_FreeSurface(tmpsurf);
 
 LoadMask;
-
 end;
 
 procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
@@ -707,6 +704,7 @@
         MakeFortsMap;
 
     AddProgress;
+
 // check for land near top
 c:= 0;
 if (GameFlags and gfBorder) <> 0 then
@@ -780,7 +778,7 @@
 
 if (GameFlags and gfForts = 0) and (maskOnly or (cPathz[ptMapCurrent] = '')) then
     AddObjects
-
+    
 else
     AddProgress();
 
@@ -836,7 +834,7 @@
         rw:= rh*2;
         end;
     if rh < rw div 2 then rh:= rw * 2;
-
+    
     ox:= (rw-LAND_WIDTH) div 2;
     oy:= rh-LAND_HEIGHT;
 
@@ -852,7 +850,7 @@
                 cbit:= bit * 8;
                 for yy:= y * lh to y * lh + 7 do
                     for xx:= x * lw + cbit to x * lw + cbit + 7 do
-                        if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0)
+                        if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0) 
                            and (Land[yy-oy, xx-ox] <> 0) then
                             inc(t);
                 if t > 8 then
@@ -875,10 +873,8 @@
 var adler, i: LongInt;
 begin
     adler:= 1;
-     for i:= 0 to LAND_HEIGHT-1 do
-       begin
+    for i:= 0 to LAND_HEIGHT-1 do
         adler:= Adler32Update(adler, @Land[i,0], LAND_WIDTH);
-       end;
     s:= 'M' + IntToStr(adler) + cScriptName;
 
     chLandCheck(s);
--- a/hedgewars/uLandGenMaze.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandGenMaze.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -16,11 +16,6 @@
     DIR_S: direction = (x: 0; y: 1);
     DIR_W: direction = (x: -1; y: 0);
 
-{xymeng : make all dynamic arrays static }
-const max_num_cells_x = 4096 div 128;
-   max_num_cells_y    = 4096 div 128;
-   max_num_steps      = 3;
-
 operator = (const a, b: direction) c: Boolean;
 begin
     c := (a.x = b.x) and (a.y = b.y);
@@ -32,42 +27,42 @@
     braidness = 10;
 
 type
-   cell_t = record x,y	       : LongInt
-	    end;
-   
-var x, y		       : LongInt;
-    cellsize		       : LongInt; //selected by the user in the gui
+   cell_t = record x,y         : LongInt
+        end;
+
+var x, y               : LongInt;
+    cellsize               : LongInt; //selected by the user in the gui
     seen_cells_x, seen_cells_y : LongInt; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another
     num_edges_x, num_edges_y   : LongInt; //number of resulting edges that need to be vertexificated
     num_cells_x, num_cells_y   : LongInt; //actual number of cells, depending on cell size
 
 
-    seen_list		       : array of array of LongInt;
-    xwalls		       : array of array of Boolean;
-    ywalls		       : array of array of Boolean;
-    x_edge_list		       : array of array of Boolean;
-    y_edge_list		       : array of array of Boolean;
-    maze		       : array of array of Boolean;
+    seen_list              : array of array of LongInt;
+    xwalls             : array of array of Boolean;
+    ywalls             : array of array of Boolean;
+    x_edge_list            : array of array of Boolean;
+    y_edge_list            : array of array of Boolean;
+    maze               : array of array of Boolean;
 
-    pa			       : TPixAr;
-    num_vertices	       : LongInt;
-    off_y		       : LongInt;
-    num_steps		       : LongInt;
-    current_step	       : LongInt;
-   
-    step_done		       : array of Boolean;
-   
-    done		       : Boolean;
+    pa                 : TPixAr;
+    num_vertices           : LongInt;
+    off_y              : LongInt;
+    num_steps              : LongInt;
+    current_step           : LongInt;
 
-{   last_cell		       : array 0..3 of record x, y :LongInt ; end;
-    came_from		       : array of array of record x, y: LongInt; end;
-    came_from_pos	       : array of LongInt;
+    step_done              : array of Boolean;
+
+    done               : Boolean;
+
+{   last_cell              : array 0..3 of record x, y :LongInt ; end;
+    came_from              : array of array of record x, y: LongInt; end;
+    came_from_pos          : array of LongInt;
 }
     last_cell : array of cell_t;
     came_from : array of array of cell_t;
     came_from_pos: array of LongInt;
-   
-    maze_inverted					   : Boolean;
+
+    maze_inverted                      : Boolean;
 
 function when_seen(x: LongInt; y: LongInt): LongInt;
 begin
@@ -127,7 +122,7 @@
         //or just warn that inverted+braid+indestructible terrain != good idea
         begin
             case dir.x of
-            
+
                 -1:
                 if x > 0 then
                     ywalls[x-1, y] := false;
@@ -197,10 +192,10 @@
     last_cell[current_step].x := came_from[current_step, came_from_pos[current_step]].x;
     last_cell[current_step].y := came_from[current_step, came_from_pos[current_step]].y;
     came_from_pos[current_step] := came_from_pos[current_step] - 1;
-    
+
     if came_from_pos[current_step] >= 0 then
         see_cell()
-        
+
     else
         step_done[current_step] := true;
     end;
@@ -227,7 +222,7 @@
         tmp_x := cellsize
     else
         tmp_x := cellsize * 2 div 3;
-        
+
     if maze_inverted or (y mod 2 = 0) then
         tmp_y := cellsize
     else
@@ -337,11 +332,11 @@
 num_cells_x := LAND_WIDTH div cellsize;
 if not odd(num_cells_x) then
     num_cells_x := num_cells_x - 1; //needs to be odd
-    
+
 num_cells_y := LAND_HEIGHT div cellsize;
 if not odd(num_cells_y) then
     num_cells_y := num_cells_y - 1;
-    
+
 num_edges_x := num_cells_x - 1;
 num_edges_y := num_cells_y - 1;
 
@@ -352,7 +347,7 @@
     num_steps := 3 //TODO randomize, between 3 and 5?
 else
     num_steps := 1;
-    
+
 SetLength(step_done, num_steps);
 SetLength(last_cell, num_steps);
 SetLength(came_from_pos, num_steps);
@@ -376,7 +371,7 @@
 SetLength(y_edge_list, num_cells_x, num_edges_y);
 SetLength(maze, num_cells_x, num_cells_y);
 
-   
+
 num_vertices := 0;
 
 playHeight := num_cells_y * cellsize;
--- a/hedgewars/uLandGraphics.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandGraphics.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uLandObjects.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandObjects.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -94,7 +94,7 @@
 begin
     BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0);
 end;
-    
+
 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; LandFlags: Word);
 var p: PLongwordArray;
     x, y: Longword;
@@ -164,7 +164,7 @@
                 LandPixels[cpY + y, cpX + x]:= p^[x];
             end
         else
-            if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then 
+            if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
                 LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
 
         if (Land[cpY + y, cpX + x] <= lfAllObjMask) or (Land[cpY + y, cpX + x] and lfObject <> 0)  then
@@ -277,7 +277,7 @@
     rr.x:= x1;
     while rr.x < x2 do
         begin
-        if cIce then 
+        if cIce then
             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce)
         else
             BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf);
--- a/hedgewars/uLandPainted.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandPainted.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 procedure freeModule;
 
 implementation
-uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uDebug, uScript;
+uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uScript;
 
 type PointRec = packed record
     X, Y: SmallInt;
--- a/hedgewars/uLandTemplates.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandTemplates.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -65,7 +65,7 @@
       );
       Template0FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template1Points: array[0..15] of TSDL_Rect =
@@ -89,7 +89,7 @@
       );
       Template1FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template2Points: array[0..21] of TSDL_Rect =
@@ -119,7 +119,7 @@
       );
       Template2FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template3Points: array[0..16] of TSDL_Rect =
@@ -144,7 +144,7 @@
       );
       Template3FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template4Points: array[0..22] of TSDL_Rect =
@@ -175,7 +175,7 @@
       );
       Template4FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template5Points: array[0..15] of TSDL_Rect =
@@ -199,7 +199,7 @@
        );
       Template5FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template6Points: array[0..13] of TSDL_Rect =
@@ -221,7 +221,7 @@
        );
       Template6FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template7Points: array[0..5] of TSDL_Rect =
@@ -235,7 +235,7 @@
       );
       Template7FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 
@@ -264,7 +264,7 @@
       );
       Template8FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template9Points: array[0..31] of TSDL_Rect =
@@ -304,7 +304,7 @@
       );
       Template9FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template10Points: array[0..13] of TSDL_Rect =
@@ -326,7 +326,7 @@
       );
       Template10FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template11Points: array[0..9] of TSDL_Rect =
@@ -344,7 +344,7 @@
       );
       Template11FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template12Points: array[0..13] of TSDL_Rect =
@@ -366,7 +366,7 @@
       );
       Template12FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template13Points: array[0..15] of TSDL_Rect =
@@ -390,7 +390,7 @@
       );
       Template13FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template14Points: array[0..13] of TSDL_Rect =
@@ -412,7 +412,7 @@
       );
       Template14FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template15Points: array[0..23] of TSDL_Rect =
@@ -444,7 +444,7 @@
       );
       Template15FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template16Points: array[0..28] of TSDL_Rect =
@@ -481,7 +481,7 @@
       );
       Template16FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 
 const Template17Points: array[0..13] of TSDL_Rect =
@@ -503,7 +503,7 @@
       );
       Template17FPoints: array[0..0] of TPoint =
       (
-       (x: 1023; y:    0)
+       (X: 1023; Y:    0)
       );
 //////////////////// MIXING AND MATCHING ORIGINAL //////////////////////////////////////
 const Template18Points: array[0..32] of TSDL_Rect =
@@ -544,7 +544,7 @@
       );
       Template18FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template19Points: array[0..44] of TSDL_Rect =
@@ -597,7 +597,7 @@
       );
       Template19FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template20Points: array[0..45] of TSDL_Rect =
@@ -651,7 +651,7 @@
       );
       Template20FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template21Points: array[0..30] of TSDL_Rect =
@@ -690,7 +690,7 @@
       );
       Template21FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template22Points: array[0..38] of TSDL_Rect =
@@ -737,7 +737,7 @@
       );
       Template22FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template23Points: array[0..29] of TSDL_Rect =
@@ -775,7 +775,7 @@
        );
       Template23FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template24Points: array[0..23] of TSDL_Rect =
@@ -807,7 +807,7 @@
        );
       Template24FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template25Points: array[0..19] of TSDL_Rect =
@@ -835,7 +835,7 @@
       );
       Template25FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 
@@ -896,7 +896,7 @@
       );
       Template26FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template27Points: array[0..42] of TSDL_Rect =
@@ -947,7 +947,7 @@
       );
       Template27FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template28Points: array[0..29] of TSDL_Rect =
@@ -985,7 +985,7 @@
       );
       Template28FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template29Points: array[0..37] of TSDL_Rect =
@@ -1031,7 +1031,7 @@
       );
       Template29FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template30Points: array[0..30] of TSDL_Rect =
@@ -1070,7 +1070,7 @@
       );
       Template30FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template31Points: array[0..32] of TSDL_Rect =
@@ -1111,7 +1111,7 @@
       );
       Template31FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template32Points: array[0..29] of TSDL_Rect =
@@ -1149,7 +1149,7 @@
       );
       Template32FPoints: array[0..0] of TPoint =
       (
-         (x: 2047; y:    0)
+         (X: 2047; Y:    0)
       );
 
 const Template33Points: array[0..45] of TSDL_Rect =
@@ -1203,7 +1203,7 @@
       );
       Template33FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template34Points: array[0..25] of TSDL_Rect =
@@ -1237,7 +1237,7 @@
       );
       Template34FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 const Template35Points: array[0..48] of TSDL_Rect =
@@ -1294,7 +1294,7 @@
       );
       Template35FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 ///////////////////////// CAVERNS ///////////////////////////////////
@@ -1322,7 +1322,7 @@
       );
       Template36FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 ////////////////////////////// ... Silly ...  ////////////////////////////////
 /// Ok. Tiy does not care for these.  Perhaps they could be saved.
@@ -1363,7 +1363,7 @@
       );
       Template37FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 // attempt to make a series of moderate hills/valleys - was before I really figured out the whole probabilities thing
 const Template38Points: array[0..16] of TSDL_Rect =
@@ -1388,7 +1388,7 @@
       );
       Template38FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 
 // 8 tiny islands
@@ -1437,7 +1437,7 @@
       );
       Template39FPoints: array[0..0] of TPoint =
       (
-       (x: 512; y:    0)
+       (X: 512; Y:    0)
       );
 const Template40Points: array[0..7] of TSDL_Rect =
       (
@@ -1452,7 +1452,7 @@
       );
       Template40FPoints: array[0..0] of TPoint =
       (
-       (x: 512; y:    0)
+       (X: 512; Y:    0)
       );
 // Many islands
 const Template41Points: array[0..86] of TSDL_Rect =
@@ -1547,7 +1547,7 @@
       );
       Template41FPoints: array[0..0] of TPoint =
       (
-       (x: 2047; y:    0)
+       (X: 2047; Y:    0)
       );
 // 2 tiny islands
 const Template42Points: array[0..13] of TSDL_Rect =
@@ -1569,7 +1569,7 @@
       );
       Template42FPoints: array[0..0] of TPoint =
       (
-       (x: 512; y:    0)
+       (X: 512; Y:    0)
       );
 // Many islands
 const Template43Points: array[0..173] of TSDL_Rect =
@@ -1751,7 +1751,7 @@
       );
       Template43FPoints: array[0..0] of TPoint =
       (
-       (x: 4095; y:    0)
+       (X: 4095; Y:    0)
       );
 
 // 3 large caverns
@@ -1775,12 +1775,12 @@
       );
       Template44FPoints: array[0..5] of TSDL_Rect =
       (
-       (x:   1; y:  90; w:   0; h:   0),
-       (x:   1; y: 500; w:   0; h:   0),
-       (x:4095; y: 500; w:   0; h:   0),
-       (x:   1; y:1200; w:   0; h:   0),
-       (x:4095; y:1200; w:   0; h:   0),
-       (x:   1; y:2010; w:   0; h:   0)
+       (X:   1; Y:  90; w:   0; h:   0),
+       (X:   1; Y: 500; w:   0; h:   0),
+       (X:4095; Y: 500; w:   0; h:   0),
+       (X:   1; Y:1200; w:   0; h:   0),
+       (X:4095; Y:1200; w:   0; h:   0),
+       (X:   1; Y:2010; w:   0; h:   0)
       );
 
 // large caverns with an island
@@ -1801,9 +1801,9 @@
       );
       Template45FPoints: array[0..2] of TSDL_Rect =
       (
-       (x:   1; y:   1; w:   0; h:   0),
-       (x:   1; y:2047; w:   0; h:   0),
-       (x:1005; y: 805; w:   0; h:   0)
+       (X:   1; Y:   1; w:   0; h:   0),
+       (X:   1; Y:2047; w:   0; h:   0),
+       (X:1005; Y: 805; w:   0; h:   0)
       );
 
 ////////////////////////////////////////////////////////////////////////
--- a/hedgewars/uLandTexture.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLandTexture.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,11 +39,10 @@
             tex: PTexture;
             end;
 
-var
-    LandTextures : array of array of TLandRecord;
-    tmpPixels	 : array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
-    LANDTEXARW	 : LongWord;
-    LANDTEXARH	 : LongWord;
+var LandTextures: array of array of TLandRecord;
+    tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
+    LANDTEXARW: LongWord;
+    LANDTEXARH: LongWord;
 
 function Pixels(x, y: Longword): Pointer;
 var ty: Longword;
@@ -199,6 +198,7 @@
         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
         end;
+
     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
 end;
 
--- a/hedgewars/uLocale.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uLocale.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,21 +26,24 @@
 
 procedure LoadLocale(FileName: shortstring);
 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
-function  FormatA(fmt: ansistring; var arg: ansistring): ansistring;
-function  GetEventString(e: TEventId): ansistring;
+function  FormatA(fmt: PChar; arg: ansistring): ansistring;
+function  GetEventString(e: TEventId): PChar;
+procedure initModule;
+procedure freeModule;
 
 {$IFDEF HWLIBRARY}
 procedure LoadLocaleWrapper(str: pchar); cdecl; export;
 {$ENDIF}
 
 implementation
-uses uRandom, uUtils, uVariables, uDebug, uPhysFSLayer;
+uses uRandom, uVariables, uDebug, uPhysFSLayer, sysutils;
 
-var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
+var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of PChar;
     trevt_n: array[TEventId] of integer;
 
 procedure LoadLocale(FileName: shortstring);
-var s: ansistring = '';
+var s: PChar = nil;
+    sc: PChar;
     f: pfsFile;
     a, b, c: LongInt;
     first: array[TEventId] of boolean;
@@ -57,47 +60,48 @@
     while not pfsEof(f) do
         begin
         pfsReadLnA(f, s);
-        if Length(s) = 0 then
-            continue;
-        if (s[1] < '0') or (s[1] > '9') then
-            continue;
-        TryDo(Length(s) > 6, 'Load locale: empty string', true);
-        val(s[1]+s[2], a{$IFNDEF PAS2C}, c{$ENDIF});
-        {$IFNDEF PAS2C}TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);{$ENDIF}
-        TryDo(s[3] = ':', 'Load locale: ":" expected', true);
-        val(s[4]+s[5], b{$IFNDEF PAS2C}, c{$ENDIF});
-        {$IFNDEF PAS2C}TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);{$ENDIF}
-        TryDo(s[6] = '=', 'Load locale: "=" expected', true);
-        Delete(s, 1, 6);
-        case a of
-            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
-                trammo[TAmmoStrId(b)]:= s;
-            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then
-                trmsg[TMsgStrId(b)]:= s;
-            2: if (b >=0) and (b <= ord(High(TEventId))) then
-                begin
-                TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false);
-                if first[TEventId(b)] then
+        if (Length(s) > 0) and (s[0] >= '0') and (s[0] <= '9') then
+            begin
+            TryDo(Length(s) > 6, 'Load locale: empty string', true);
+            val(s[0]+s[1], a, c);
+            TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
+            TryDo(s[2] = ':', 'Load locale: ":" expected', true);
+            val(s[3]+s[4], b, c);
+            TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
+            TryDo(s[5] = '=', 'Load locale: "=" expected', true);
+            sc:= StrAlloc(length(s) - 5);
+            StrCopy(sc, @s[6]);
+            case a of
+                0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
+                    trammo[TAmmoStrId(b)]:= sc;
+                1: if (b >=0) and (b <= ord(High(TMsgStrId))) then
+                    trmsg[TMsgStrId(b)]:= sc;
+                2: if (b >=0) and (b <= ord(High(TEventId))) then
                     begin
-                    trevt_n[TEventId(b)]:= 0;
-                    first[TEventId(b)]:= false;
+                    TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false);
+                    if first[TEventId(b)] then
+                        begin
+                        trevt_n[TEventId(b)]:= 0;
+                        first[TEventId(b)]:= false;
+                        end;
+                    trevt[TEventId(b)][trevt_n[TEventId(b)]]:= sc;
+                    inc(trevt_n[TEventId(b)]);
                     end;
-                trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
-                inc(trevt_n[TEventId(b)]);
-                end;
-            3: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
-                trammoc[TAmmoStrId(b)]:= s;
-            4: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
-                trammod[TAmmoStrId(b)]:= s;
-            5: if (b >=0) and (b <= ord(High(TGoalStrId))) then
-                trgoal[TGoalStrId(b)]:= s;
-           end;
-       end;
+                3: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
+                    trammoc[TAmmoStrId(b)]:= sc;
+                4: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
+                    trammod[TAmmoStrId(b)]:= sc;
+                5: if (b >=0) and (b <= ord(High(TGoalStrId))) then
+                    trgoal[TGoalStrId(b)]:= sc;
+            end;
+            end;
+        StrDispose(s);
+        end;
    pfsClose(f);
    end;
 end;
 
-function GetEventString(e: TEventId): ansistring;
+function GetEventString(e: TEventId): PChar;
 begin
     if trevt_n[e] = 0 then // no messages for this event type?
         GetEventString:= '*missing translation*'
@@ -115,14 +119,17 @@
     Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
 end;
 
-function FormatA(fmt: ansistring; var arg: ansistring): ansistring;
+function FormatA(fmt: PChar; arg: ansistring): ansistring;
 var i: LongInt;
+    s: ansistring;
 begin
-i:= Pos('%1', fmt);
+s:= fmt;
+
+i:= Pos('%1', s);
 if i = 0 then
-    FormatA:= fmt
+    FormatA:= s
 else
-    FormatA:= copy(fmt, 1, i - 1) + arg + FormatA(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
+    FormatA:= copy(s, 1, i - 1) + arg + FormatA(PChar(copy(s, i + 2, Length(s) - i - 1)), arg)
 end;
 
 {$IFDEF HWLIBRARY}
@@ -132,4 +139,22 @@
 end;
 {$ENDIF}
 
+procedure initModule;
+var e: TEventId;
+    i: LongInt;
+begin
+    for e:= Low(TEventId) to High(TEventId) do
+        for i:= 0 to Pred(MAX_EVENT_STRINGS) do
+            trevt[e][i]:= nil;
+end;
+
+procedure freeModule;
+var e: TEventId;
+    i: LongInt;
+begin
+    for e:= Low(TEventId) to High(TEventId) do
+        for i:= 0 to Pred(trevt_n[e]) do
+            StrDispose(trevt[e][i]);
+end;
+
 end.
--- a/hedgewars/uMatrix.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uMatrix.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -27,7 +27,7 @@
 const
     MATRIX_MODELVIEW:Integer = 0;
     MATRIX_PROJECTION:Integer = 1;
-  
+
 procedure MatrixLoadIdentity(out Result: TMatrix4x4f);
 procedure MatrixMultiply(out Result: TMatrix4x4f; const lhs, rhs: TMatrix4x4f);
 
@@ -85,7 +85,7 @@
     m[0,3]:=0;m[1,3]:=0;m[2,3]:=0;m[3,3]:=1;
 
     MatrixMultiply(t, MatrixStacks[CurMatrix].stack[MatrixStacks[CurMatrix].top], m);
-    MatrixStacks[CurMatrix].stack[MatrixStacks[CurMatrix].top] := t; 
+    MatrixStacks[CurMatrix].stack[MatrixStacks[CurMatrix].top] := t;
 end;
 
 procedure hglTranslatef(x: GLfloat; y: GLfloat; z: GLfloat);
@@ -114,7 +114,7 @@
     a:=a * 3.14159265368 / 180;
     c:=cos(a);
     s:=sin(a);
-    
+
     l := 1.0 / sqrt(x * x + y * y + z * z);
     xn := x * l;
     yn := y * l;
@@ -144,8 +144,8 @@
 
 procedure hglMVP(var res: TMatrix4x4f);
 begin
-    MatrixMultiply(res, 
-                   MatrixStacks[MATRIX_PROJECTION].stack[MatrixStacks[MATRIX_PROJECTION].top], 
+    MatrixMultiply(res,
+                   MatrixStacks[MATRIX_PROJECTION].stack[MatrixStacks[MATRIX_PROJECTION].top],
                    MatrixStacks[MATRIX_MODELVIEW].stack[MatrixStacks[MATRIX_MODELVIEW].top]);
 end;
 
@@ -211,7 +211,7 @@
     Result[0,1]:=lhs[0,0]*rhs[1,0] + lhs[1,0]*rhs[1,1] + lhs[2,0]*rhs[1,2] + lhs[3,0]*rhs[1,3];
     Result[0,2]:=lhs[0,0]*rhs[2,0] + lhs[1,0]*rhs[2,1] + lhs[2,0]*rhs[2,2] + lhs[3,0]*rhs[2,3];
     Result[0,3]:=lhs[0,0]*rhs[3,0] + lhs[1,0]*rhs[3,1] + lhs[2,0]*rhs[3,2] + lhs[3,0]*rhs[3,3];
-  
+
     Result[1,0]:=lhs[0,1]*rhs[0,0] + lhs[1,1]*rhs[0,1] + lhs[2,1]*rhs[0,2] + lhs[3,1]*rhs[0,3];
     Result[1,1]:=lhs[0,1]*rhs[1,0] + lhs[1,1]*rhs[1,1] + lhs[2,1]*rhs[1,2] + lhs[3,1]*rhs[1,3];
     Result[1,2]:=lhs[0,1]*rhs[2,0] + lhs[1,1]*rhs[2,1] + lhs[2,1]*rhs[2,2] + lhs[3,1]*rhs[2,3];
--- a/hedgewars/uMisc.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uMisc.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -271,7 +271,6 @@
 var convertedSurf: PSDL_Surface;
 begin
     doSurfaceConversion:= tmpsurf;
-{$IFNDEF WEBGL}
     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
        (tmpsurf^.format^.bitsperpixel = 24) then
     begin
@@ -279,7 +278,6 @@
         SDL_FreeSurface(tmpsurf);
         doSurfaceConversion:= convertedSurf;
     end;
-{$ENDIF}
 end;
 
 {$IFDEF SDL2}
@@ -328,4 +326,4 @@
 {$ENDIF}
 end;
 
-end.		
+end.
--- a/hedgewars/uPhysFSLayer.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uPhysFSLayer.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -3,6 +3,8 @@
 interface
 uses SDLh, LuaPas;
 
+{$INCLUDE "config.inc"}
+
 const PhysfsLibName = {$IFDEF PHYSFS_INTERNAL}'libhwphysfs'{$ELSE}'libphysfs'{$ENDIF};
 const PhyslayerLibName = 'libphyslayer';
 
@@ -23,38 +25,33 @@
 function pfsClose(f: PFSFile): boolean;
 
 procedure pfsReadLn(f: PFSFile; var s: shortstring);
-procedure pfsReadLnA(f: PFSFile; var s: ansistring);
+procedure pfsReadLnA(f: PFSFile; var s: PChar);
 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
 function pfsEOF(f: PFSFile): boolean;
 
 function pfsExists(fname: shortstring): boolean;
 
-{$IFNDEF PAS2C}
 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName;
 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName;
 procedure hedgewarsMountPackage(filename: PChar); cdecl; external PhyslayerLibName;
-{$ENDIF}
 
 implementation
-uses uUtils, uVariables;
+uses uUtils, uVariables, sysutils;
 
-{$IFNDEF PAS2C}
 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external PhyslayerLibName;
 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhyslayerLibName;
 
-function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external PhysfsLibName;
+function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongBool; cdecl; external PhysfsLibName;
 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName;
 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
+function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName;
 
 procedure hedgewarsMountPackages(); cdecl; external PhyslayerLibName;
-{$ENDIF}
-
-(*****************************************************************)
 
 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
 begin
@@ -100,26 +97,34 @@
         end
 end;
 
-procedure pfsReadLnA(f: PFSFile; var s: ansistring);
-var c: char;
-    b: shortstring;
+procedure pfsReadLnA(f: PFSFile; var s: PChar);
+var l, bufsize: Longword;
+    r: Int64;
+    b: PChar;
 begin
-s:= '';
-b[0]:= #0;
+bufsize:= 256;
+s:= StrAlloc(bufsize);
+l:= 0;
 
-while (PHYSFS_readBytes(f, @c, 1) = 1) and (c <> #10) do
-    if (c <> #13) then
+repeat
+    r:= PHYSFS_readBytes(f, @s[l], 1);
+
+    if (r = 1) and (s[l] <> #13) then
         begin
-        inc(b[0]);
-        b[byte(b[0])]:= c;
-        if b[0] = #255 then
+        inc(l);
+        if l = bufsize then
             begin
-            s:= s + b;
-            b[0]:= #0
+            b:= s;
+            inc(bufsize, 256);
+            s:= StrAlloc(bufsize);
+            StrCopy(s, b);
+            StrDispose(b)
             end
         end;
 
-s:= s + b
+until (r = 0) or (s[l - 1] = #10);
+
+if (r = 0) then s[l]:= #0 else s[l - 1]:= #0
 end;
 
 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
@@ -133,9 +138,23 @@
         pfsBlockRead:= r
 end;
 
+procedure pfsMount(path: AnsiString; mountpoint: PChar);
+begin
+    if PHYSFS_mount(Str2PChar(path), mountpoint, false) then
+        AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : ok')
+    else
+        AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : FAILED ("' + PHYSFS_getLastError() + '")');
+end;
+
+procedure pfsMountAtRoot(path: AnsiString);
+begin
+    pfsMount(path, '/');
+end;
+
 procedure initModule;
 var i: LongInt;
     cPhysfsId: shortstring;
+    fp: PChar;
 begin
 {$IFDEF HWLIBRARY}
     //TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html
@@ -147,16 +166,27 @@
     i:= PHYSFS_init(Str2PChar(cPhysfsId));
     AddFileLog('[PhysFS] init: ' + inttostr(i));
 
-    i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, false);
-    AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
-    i:= PHYSFS_mount(Str2PChar(UserPathPrefix + '/Data'), nil, false);
-    AddFileLog('[PhysFS] mount ' + UserPathPrefix + '/Data: ' + inttostr(i));
+    // mount system fonts paths first
+    for i:= low(cFontsPaths) to high(cFontsPaths) do
+        begin
+            fp := cFontsPaths[i];
+            if fp <> nil then
+                pfsMount(fp, '/Fonts');
+        end;
+
+    pfsMountAtRoot(PathPrefix);
+    pfsMountAtRoot(UserPathPrefix + '/Data');
 
     hedgewarsMountPackages;
 
-    i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, false);
     // need access to teams and frontend configs (for bindings)
-    AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i)); 
+    pfsMountAtRoot(UserPathPrefix);
+
+    if cTestLua then
+        begin
+            pfsMountAtRoot(ExtractFileDir(cScriptName));
+            cScriptName := ExtractFileName(cScriptName);
+        end;
 end;
 
 procedure freeModule;
--- a/hedgewars/uRandom.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uRandom.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uRender.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uRender.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
 
 interface
 
-uses SDLh, uTypes, GLunit, uConsts, uStore, uMatrix;
+uses SDLh, uTypes, GLunit, uConsts, uStore{$IFDEF GL2}, uMatrix{$ENDIF};
 
 procedure DrawSprite            (Sprite: TSprite; X, Y, Frame: LongInt);
 procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
@@ -415,7 +415,7 @@
 if (X + SpritesData[Sprite].Width > RightX) then
     r.w:= RightX - X + 1;
 
-if (r.h < r.y) or (r.w < r.x) then 
+if (r.h < r.y) or (r.w < r.x) then
     exit;
 
 dec(r.h, r.y);
@@ -459,7 +459,7 @@
     SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
     glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
     untint;
-    
+
     glPopMatrix;
 
     glEnable(GL_TEXTURE_2D);
@@ -532,7 +532,7 @@
 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
 begin
     Tint(r, g, b, a);
-    DrawCircle(X, Y, Radius, Width); 
+    DrawCircle(X, Y, Radius, Width);
     untint;
 end;
 
@@ -681,14 +681,16 @@
     end;
 {$ELSE}
 begin
-{widget:= widget; // avoid hint}
+widget:= widget; // avoid hint
 {$ENDIF}
 end;
 
 procedure Tint(r, g, b, a: Byte); inline;
 var
     nc, tw: Longword;
+    {$IFDEF GL2}
     scale:Real = 1.0/255.0;
+    {$ENDIF}
 begin
     nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
 
--- a/hedgewars/uRenderUtils.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uRenderUtils.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -191,12 +191,12 @@
     numFramesFirstCol:= SpritesData[sprite].imageHeight div SpritesData[sprite].Height;
     row:= Frame mod numFramesFirstCol;
     col:= Frame div numFramesFirstCol;
-    
-    copyToXYFromRect(SpritesData[sprite].Surface, dest, 
-             col*SpritesData[sprite].Width, 
-             row*SpritesData[sprite].Height, 
-             SpritesData[sprite].Width, 
-             spritesData[sprite].Height, 
+
+    copyToXYFromRect(SpritesData[sprite].Surface, dest,
+             col*SpritesData[sprite].Width,
+             row*SpritesData[sprite].Height,
+             SpritesData[sprite].Width,
+             spritesData[sprite].Height,
              x,y);
 end;
 
@@ -217,7 +217,7 @@
     dy:= abs(y1-y0);
     if x0 < x1 then sx:= 1 else sx:= -1;
     if y0 < y1 then sy:= 1 else sy:= -1;
-    err:= dx-dy; 
+    err:= dx-dy;
 
     while(true) do
         begin
@@ -346,7 +346,7 @@
         begin
         w:= 0;
         i:= round(Sqrt(length(s)) * 2);
-       // s:= WrapText(s, #1, chars, i);
+        s:= WrapText(s, #1, chars, i);
         pos:= 1; prevpos:= 0; line:= 0;
     // Find the longest line for the purposes of centring the text.  Font dependant.
         while pos <= length(s) do
--- a/hedgewars/uScript.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uScript.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@
 procedure ScriptOnGameInit;
 procedure ScriptOnScreenResize;
 procedure ScriptSetInteger(name : shortstring; value : LongInt);
+procedure ScriptSetString(name : shortstring; value : shortstring);
 
 procedure ScriptCall(fname : shortstring);
 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
@@ -109,6 +110,8 @@
 begin
     WriteLnToConsole(s);
     AddChatString(#5 + s);
+    if cTestLua then
+        halt(rtnTestLuaErr);
 end;
 
 procedure LuaParameterCountError(call, paramsyntax: shortstring; wrongcount: LongInt);
@@ -225,7 +228,7 @@
 begin
     if lua_gettop(L) = 5 then
         begin
-        ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
+        ShowMission(lua_tolstring(L, 1, nil), lua_tolstring(L, 2, nil), lua_tolstring(L, 3, nil), lua_tointeger(L, 4), lua_tointeger(L, 5));
         end
     else
         LuaParameterCountError('ShowMission', 'caption, subcaption, text, icon, time', lua_gettop(L));
@@ -269,10 +272,10 @@
 function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
 begin
     if lua_gettop(L) = 1 then
-        AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage)
+        AddCaption(lua_tolstring(L, 1, nil), cWhiteColor, capgrpMessage)
     else if lua_gettop(L) = 3 then
         begin
-        AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
+        AddCaption(lua_tolstring(L, 1, nil), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
         end
     else
         LuaParameterCountError('AddCaption', 'text[, color, captiongroup]', lua_gettop(L));
@@ -1173,7 +1176,7 @@
                 RecountTeamHealth(gear^.Hedgehog^.Team)
                 end;
             // Why did this do a "setalltoactive" ?
-            //SetAllToActive;  
+            //SetAllToActive;
             Gear^.Active:= true;
             AllInactive:= false
             end
@@ -1200,7 +1203,7 @@
 var gear: PGear;
 begin
     if lua_gettop(L) <> 3 then
-        LuaParameterCountError('SetEffect', 'gearUid, effect, enabled', lua_gettop(L))
+        LuaParameterCountError('SetEffect', 'gearUid, effect, effectState', lua_gettop(L))
     else begin
         gear := GearByUID(lua_tointeger(L, 1));
         if (gear <> nil) and (gear^.Hedgehog <> nil) then
@@ -1986,6 +1989,21 @@
         declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4));
     lc_declareachievement:= 0
 end;
+
+// stuff for testing the lua API
+function lc_endluatest(L : Plua_State) : LongInt; Cdecl;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        LuaParameterCountError('EndLuaAPITest', 'LUA_API_TEST_SUCCESSFUL or LUA_API_TEST_FAILED', lua_gettop(L));
+        lua_pushnil(L);
+        end
+    else
+        begin
+        halt(lua_tointeger(L, 1));
+        lc_endluatest:= 0;
+        end;
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -2074,7 +2092,6 @@
 ScriptSetString('Map', cMapName);
 ScriptSetString('Theme', '');
 ScriptSetString('Goals', '');
-ScriptSetString('ScriptParam', cScriptParam);
 
 ScriptCall('onGameInit');
 
@@ -2635,6 +2652,12 @@
 lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload);
 lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement);
 
+if cTestLua then
+    begin
+    ScriptSetInteger('TEST_SUCCESSFUL'  ,rtnTestSuccess);
+    ScriptSetInteger('TEST_FAILED'      ,rtnTestFailed);
+    lua_register(luaState, _P'EndLuaTest', @lc_endluatest);
+    end;
 
 ScriptClearStack; // just to be sure stack is empty
 ScriptLoaded:= false;
--- a/hedgewars/uSinTable.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uSinTable.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uSound.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uSound.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uStats.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uStats.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 var TotalRounds: LongInt;
     FinishedTurnsTotal: LongInt;
     SendHealthStatsOn : boolean = true;
-    
+
 procedure initModule;
 procedure freeModule;
 
@@ -111,7 +111,7 @@
     else if CurrentHedgehog^.stats.StepDamageRecv > 0 then
         begin
         AddVoice(sndStupid, PreviousTeam^.voicepack);
-        if CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then 
+        if CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then
             AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage);
         end
 
@@ -164,7 +164,7 @@
                 StepDamageRecv:= 0;
                 StepDamageGiven:= 0
                 end;
-                
+
 if SendHealthStatsOn then
     for t:= 0 to Pred(ClansCount) do
         with ClansArray[t]^ do
@@ -298,7 +298,7 @@
         SendStat(siKilledHHs, IntToStr(KilledHHs));
 
     // now to console
-    if winnersClan <> nil then 
+    if winnersClan <> nil then
         begin
         WriteLnToConsole('WINNERS');
         WriteLnToConsole(inttostr(winnersClan^.TeamsNumber));
@@ -307,12 +307,12 @@
         end
     else
         WriteLnToConsole('DRAW');
-        
+
     ScriptCall('onAchievementsDeclaration');
 end;
 
 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
-begin 
+begin
 if (length(id) = 0) or (length(teamname) = 0) or (length(location) = 0) then exit;
     WriteLnToConsole('ACHIEVEMENT');
     WriteLnToConsole(id);
--- a/hedgewars/uStore.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uStore.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring);
 procedure SetupOpenGL;
 procedure SetScale(f: GLfloat);
-function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
+function  RenderHelpWindow(caption, subcaption, description, extra: PChar; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
 procedure RenderWeaponTooltip(atype: TAmmoType);
 procedure ShowWeaponTooltip(x, y: LongInt);
 procedure FreeWeaponTooltip;
@@ -71,14 +71,12 @@
 procedure EndWater;
 
 implementation
-uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands
-    , uPhysFSLayer
-    , uDebug
+uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils,
+     uCommands, uPhysFSLayer, uDebug
+    {$IFDEF GL2}, uMatrix{$ENDIF}
     {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}
     {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
 
-//type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
-
 var MaxTextureSize: LongInt;
 {$IFDEF SDL2}
     SDLwindow: PSDL_Window;
@@ -97,10 +95,6 @@
     // attributes
 {$ENDIF}
 
-{$IFDEF WEBGL}
-    OpenGLSetupedBefore : boolean;
-{$ENDIF}
-
 const
     cHHFileName = 'Hedgehog';
     cCHFileName = 'Crosshair';
@@ -277,7 +271,7 @@
                         else if (month = 10) and (md = 31) then
                             Hat := 'fr_pumpkin'; // Halloween/Hedgewars' birthday
                         end;
-                    
+
                     if Hat <> 'NoHat' then
                         begin
                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
@@ -348,7 +342,7 @@
     i, imflags: LongInt;
 begin
 AddFileLog('StoreLoad()');
-WriteLnToConsole('Entering StoreLoad');
+
 if not reload then
     for fi:= Low(THWFont) to High(THWFont) do
         with Fontz[fi] do
@@ -479,7 +473,6 @@
     AddProgress;
 IMG_Quit();
 
-WriteLnToConsole('Leaving StoreLoad');
 end;
 
 {$IFNDEF PAS2C}
@@ -884,18 +877,6 @@
         cReducedQuality := cReducedQuality or rqNoBackground;
         AddFileLog('Texture size too small for backgrounds, disabling.');
         end;
-{$IFDEF WEBGL}
-    if OpenGLSetupedBefore then
-        begin
-        glViewport(0, 0, cScreenWidth, cScreenHeight);
-        hglMatrixMode(MATRIX_MODELVIEW);
-        hglLoadIdentity();
-        hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
-        hglTranslatef(0, -cScreenHeight / 2, 0);
-        exit;
-        end
-    OpenGLSetupedBefore := true;
-{$ELSE}
     // everyone loves debugging
     // find out which gpu we are using (for extension compatibility maybe?)
     AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER))));
@@ -927,7 +908,6 @@
     end;
     until (tmpint > tmpn);
 {$ENDIF}
-{$ENDIF}
     AddFileLog('');
 
     defaultFrame:= 0;
@@ -1060,38 +1040,41 @@
 
 procedure SetTexCoordPointer(p: Pointer; n: Integer);
 begin
-    {$IFDEF GL2}
+{$IFDEF GL2}
     glBindBuffer(GL_ARRAY_BUFFER, tBuffer);
     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
     glEnableVertexAttribArray(aTexCoord);
     glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
-    {$ELSE}
+{$ELSE}
+    n:= n;
     glTexCoordPointer(2, GL_FLOAT, 0, p);
-    {$ENDIF}
+{$ENDIF}
 end;
 
 procedure SetVertexPointer(p: Pointer; n: Integer);
 begin
-    {$IFDEF GL2}
+{$IFDEF GL2}
     glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
     glEnableVertexAttribArray(aVertex);
     glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
-    {$ELSE}
+{$ELSE}
+    n:= n;
     glVertexPointer(2, GL_FLOAT, 0, p);
-    {$ENDIF}
+{$ENDIF}
 end;
 
 procedure SetColorPointer(p: Pointer; n: Integer);
 begin
-    {$IFDEF GL2}
+{$IFDEF GL2}
     glBindBuffer(GL_ARRAY_BUFFER, cBuffer);
     glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW);
     glEnableVertexAttribArray(aColor);
     glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0));
-    {$ELSE}
+{$ELSE}
+    n:= n;
     glColorPointer(4, GL_UNSIGNED_BYTE, 0, p);
-    {$ENDIF}
+{$ENDIF}
 end;
 
 {$IFDEF GL2}
@@ -1100,7 +1083,9 @@
     mvp: TMatrix4x4f;
 begin
     //MatrixMultiply(mvp, mProjection, mModelview);
+{$HINTS OFF}
     hglMVP(mvp);
+{$HINTS ON}
     glUniformMatrix4fv(uCurrentMVPLocation, 1, GL_FALSE, @mvp[0, 0]);
 end;
 {$ENDIF}
@@ -1116,13 +1101,13 @@
     mProjection[2,0]:= 0.0;            mProjection[2,1]:=  0.0;             mProjection[2,2]:=1.0; mProjection[2,3]:=  0.0;
     mProjection[3,0]:= cStereoDepth;   mProjection[3,1]:=  s/2;             mProjection[3,2]:=0.0; mProjection[3,3]:=  1.0;
 
-    {$IFDEF GL2}
+{$IFDEF GL2}
     UpdateModelviewProjection;
-    {$ELSE}
+{$ELSE}
     glMatrixMode(GL_PROJECTION);
     glLoadMatrixf(@mProjection[0, 0]);
     glMatrixMode(GL_MODELVIEW);
-    {$ENDIF}
+{$ENDIF}
 end;
 *)
 
@@ -1162,30 +1147,30 @@
 
 procedure BeginWater;
 begin
-    {$IFDEF GL2}
+{$IFDEF GL2}
     glUseProgram(shaderWater);
     uCurrentMVPLocation:=uWaterMVPLocation;
     UpdateModelviewProjection;
     glDisableVertexAttribArray(aTexCoord);
     glEnableVertexAttribArray(aColor);
-    {$ELSE}
+{$ELSE}
     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     glEnableClientState(GL_COLOR_ARRAY);
-    {$ENDIF}
+{$ENDIF}
 end;
 
 procedure EndWater;
 begin
-    {$IFDEF GL2}
+{$IFDEF GL2}
     glUseProgram(shaderMain);
     uCurrentMVPLocation:=uMainMVPLocation;
     UpdateModelviewProjection;
     glDisableVertexAttribArray(aColor);
     glEnableVertexAttribArray(aTexCoord);
-    {$ELSE}
+{$ELSE}
     glDisableClientState(GL_COLOR_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    {$ENDIF}
+{$ENDIF}
 end;
 
 
@@ -1244,7 +1229,7 @@
     Step:= 0
 end;
 
-function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
+function RenderHelpWindow(caption, subcaption, description, extra: PChar; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
 var tmpsurf: PSDL_SURFACE;
     w, h, i, j: LongInt;
     font: THWFont;
@@ -1364,7 +1349,7 @@
 procedure RenderWeaponTooltip(atype: TAmmoType);
 var r: TSDL_Rect;
     i: LongInt;
-    extra: ansistring;
+    extra: PChar;
     extracolor: LongInt;
 begin
 // don't do anything if the window shouldn't be shown
@@ -1527,11 +1512,9 @@
     {$ENDIF}
         AddFileLog('Freeing old primary surface...');
     {$IFNDEF SDL2}
-    {$IFNDEF WEBGL}
         SDL_FreeSurface(SDLPrimSurface);
         SDLPrimSurface:= nil;
     {$ENDIF}
-    {$ENDIF}
 {$ENDIF}
         end;
 
@@ -1644,10 +1627,6 @@
     ProgrTex:= nil;
     SupportNPOTT:= false;
 
-{$IFDEF WEBGL}
-    OpenGLSetupedBefore := false;
-{$ENDIF}
-
     // init all ammo name texture pointers
     for ai:= Low(TAmmoType) to High(TAmmoType) do
     begin
--- a/hedgewars/uTeams.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uTeams.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
  (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
 
 unit uTeams;
 interface
-uses uConsts, uInputHandler, uRandom, uFloat, uStats, 
+uses uConsts, uInputHandler, uRandom, uFloat, uStats,
      uCollisions, uSound, uStore, uTypes, uScript
      {$IFDEF USE_TOUCH_INTERFACE}, uWorld{$ENDIF};
 
@@ -596,7 +596,7 @@
     CurrentTeam^.TeamName:= ts;
     CurrentTeam^.PlayerHash:= s;
     loadTeamBinds(ts);
-    
+
     if GameType in [gmtDemo, gmtSave, gmtRecord] then
         CurrentTeam^.ExtDriven:= true;
 
@@ -619,7 +619,6 @@
 end;
 
 procedure chBind(var id: shortstring);
-var i : Integer;
 begin
     if CurrentTeam = nil then
         exit;
--- a/hedgewars/uTextures.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uTextures.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uTypes.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uTypes.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -268,7 +268,7 @@
 // These are frequently overridden to serve some other purpose
             Pos: Longword;           // Commonly overridden.  Example use is posCase values in uConsts.
             Angle, Power : Longword; // Used for hog aiming/firing.  Angle is rarely used as an Angle otherwise.
-            Timer : LongWord;        // Typically used for some sort of gear timer. Time to explosion, remaining fuel...
+            Timer, WDTimer : LongWord;        // Typically used for some sort of gear timer. Time to explosion, remaining fuel...
             Tag: LongInt;            // Quite generic. Variety of uses.
             FlightTime: Longword;    // Initially added for batting of hogs to determine homerun. Used for some firing delays
             MsgParam: LongWord;      // Initially stored a set of messages. So usually gm values like Message. Frequently overriden
@@ -413,7 +413,7 @@
             CurrTeam: LongWord;
             ClanHealth: LongInt;
             ClanIndex: LongInt;
-            TurnNumber: LongInt;{xymeng, org:LongWord}
+            TurnNumber: LongWord;
             Flawless: boolean;
             end;
 
--- a/hedgewars/uUtils.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uUtils.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -331,7 +331,6 @@
 procedure AddFileLog(s: shortstring);
 begin
 // s:= s;
-{$IFNDEF WEBGL}
 {$IFDEF DEBUGFILE}
 
 {$IFDEF USE_VIDEO_RECORDING}
@@ -345,7 +344,6 @@
 {$ENDIF}
 
 {$ENDIF}
-{$ENDIF}
 end;
 
 procedure AddFileLogRaw(s: pchar); cdecl;
@@ -395,7 +393,7 @@
        ((#$F900  <= u) and (u <= #$FAFF))  or // CJK Compatibility Ideographs
        ((#$FE30  <= u) and (u <= #$FE4F))  or // CJK Compatibility Forms
        ((#$FF66  <= u) and (u <= #$FF9D)))    // halfwidth katakana
-       then 
+       then
         begin
             CheckCJKFont:=  THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) );
             exit;
@@ -470,7 +468,7 @@
             r[i]:= '?'
             else
             r[i]:= s[i];
-            
+
     sanitizeForLog:= r
 end;
 
--- a/hedgewars/uVariables.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uVariables.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -81,7 +81,7 @@
 
     CheckSum        : LongWord;
     CampaignVariable: shortstring;
-    GameTicks       : LongInt; {xymeng:originally LongWord}
+    GameTicks       : LongWord;
     GameState       : TGameState;
     GameType        : TGameType;
     InputMask       : LongWord;
@@ -213,7 +213,7 @@
 
     LuaGoals        : shortstring;
 
-    LuaTemplateNumber : LongInt; {org: LongWord}
+    LuaTemplateNumber : LongWord;
 
     LastVoice : TVoice = ( snd: sndNone; voicepack: nil );
 
@@ -720,7 +720,7 @@
             TimeAfterTurn: Longword;
             minAngle, maxAngle: Longword;
             isDamaging: boolean;
-            SkipTurns: LongInt; {xymeng, orinally: LongWord}
+            SkipTurns: LongWord;
             PosCount: Longword;
             PosSprite: TSprite;
             ejectX, ejectY: Longint;
@@ -2385,20 +2385,19 @@
     aTexCoord: GLint;
     aColor: GLint;
 
-var trammo:  array[TAmmoStrId] of ansistring;   // name of the weapon
-    trammoc: array[TAmmoStrId] of ansistring;   // caption of the weapon
-    trammod: array[TAmmoStrId] of ansistring;   // description of the weapon
-    trmsg:   array[TMsgStrId]  of ansistring;   // message of the event
-    trgoal:  array[TGoalStrId] of ansistring;   // message of the goal
+var trammo:  array[TAmmoStrId] of PChar;   // name of the weapon
+    trammoc: array[TAmmoStrId] of PChar;   // caption of the weapon
+    trammod: array[TAmmoStrId] of PChar;   // description of the weapon
+    trmsg:   array[TMsgStrId]  of PChar;   // message of the event
+    trgoal:  array[TGoalStrId] of PChar;   // message of the goal
+    cTestLua : Boolean;
 
 procedure preInitModule;
 procedure initModule;
 procedure freeModule;
 
 implementation
-{$IFNDEF PAS2C}
-uses strutils;
-{$ENDIF}
+uses strutils, sysutils;
 
 procedure preInitModule;
 begin
@@ -2427,6 +2426,9 @@
     PathPrefix      := './';
     GameType        := gmtLocal;
     cOnlyStats      := False;
+    cScriptName     := '';
+    cScriptParam    := '';
+    cTestLua        := False;
 
 {$IFDEF USE_VIDEO_RECORDING}
     RecPrefix          := '';
@@ -2440,7 +2442,22 @@
 end;
 
 procedure initModule;
+var asid: TAmmoStrId;
+    msid: TMsgStrId;
+    gsid: TGoalStrId;
 begin
+    for asid:= Low(TAmmoStrId) to High(TAmmoStrId) do
+        begin
+        trammo[asid]:= nil;
+        trammoc[asid]:= nil;
+        trammod[asid]:= nil;
+        end;
+    for msid:= Low(TMsgStrId) to High(TMsgStrId) do
+        trmsg[msid]:= nil;
+    for gsid:= Low(TGoalStrId) to High(TGoalStrId) do
+        trgoal[gsid]:= nil;
+
+// TODO: fixme
 {$IFDEF PAS2C}
     cLocale:= 'en';
 {$ELSE}
@@ -2577,8 +2594,6 @@
     fastUntilLag    := false;
     fastScrolling   := false;
     autoCameraOn    := true;
-    cScriptName     := '';
-    cScriptParam    := '';
     cSeed           := '';
     cVolumeDelta    := 0;
     cHasFocus       := true;
@@ -2629,7 +2644,20 @@
 end;
 
 procedure freeModule;
+var asid: TAmmoStrId;
+    msid: TMsgStrId;
+    gsid: TGoalStrId;
 begin
+    for asid:= Low(TAmmoStrId) to High(TAmmoStrId) do
+        begin
+        if trammo[asid] <> nil then StrDispose(trammo[asid]);
+        if trammoc[asid] <> nil then StrDispose(trammoc[asid]);
+        if trammod[asid] <> nil then StrDispose(trammod[asid]);
+        end;
+    for msid:= Low(TMsgStrId) to High(TMsgStrId) do
+        if trmsg[msid] <> nil then StrDispose(trmsg[msid]);
+    for gsid:= Low(TGoalStrId) to High(TGoalStrId) do
+        if trgoal[gsid] <> nil then StrDispose(trgoal[gsid]);
 end;
 
 end.
--- a/hedgewars/uVideoRec.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uVideoRec.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
--- a/hedgewars/uVisualGears.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uVisualGears.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -219,7 +219,7 @@
                               else
                                   DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
                   vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
-               vgtStraightShot: begin 
+               vgtStraightShot: begin
                                 if Gear^.dX < 0 then
                                     i:= -1
                                 else
--- a/hedgewars/uVisualGearsHandlers.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,9 +24,9 @@
  * => The usage of safe functions or data types (e.g. GetRandom() or hwFloat)
  * is usually not necessary and therefore undesirable.
  *)
- 
-{$INCLUDE "options.inc"} 
- 
+
+{$INCLUDE "options.inc"}
+
 unit uVisualGearsHandlers;
 
 interface
--- a/hedgewars/uVisualGearsList.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uVisualGearsList.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 procedure DeleteVisualGear(Gear: PVisualGear);
 function  VisualGearByUID(uid : Longword) : PVisualGear;
 
-const 
+const
     cExplFrameTicks = 110;
 
 var VGCounter: LongWord;
@@ -75,7 +75,7 @@
     vgtEvilTrace,
     vgtNote,
     vgtSmoothWindBar])) then
-    
+
         exit;
 
 inc(VGCounter);
@@ -289,7 +289,7 @@
                 if random(2) = 0 then
                     dx := -dx;
                 end;
-      vgtNote: 
+      vgtNote:
                 begin
                 dx:= 0.005 * (random(15) + 10);
                 dy:= -0.001 * (random(40) + 20);
@@ -306,7 +306,7 @@
                 Frame:= 7;
                 Angle:= 0;
                 end;
-vgtSmoothWindBar: 
+vgtSmoothWindBar:
                 begin
                 Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change
                 Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
@@ -332,7 +332,7 @@
 case Gear^.Kind of
     vgtFlake: if cFlattenFlakes then
         gear^.Layer:= 0
-              else if random(3) = 0 then 
+              else if random(3) = 0 then
                   begin
                   gear^.Scale:= 0.5;
                   gear^.Layer:= 0   // 33% - far back
--- a/hedgewars/uWeb.pas	Thu Jan 09 19:10:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-
-// defines functions used for web port
-
-unit uWeb;
-interface
-
-type
-    TResourceList = record
-        count : Integer;
-        files : array[0..500] of shortstring;
-    end;
-
-function generateResourceList:TResourceList;
-
-implementation
-
-uses uConsts, uVariables, uTypes;
-
-function readThemeCfg:TResourceList; forward;
-
-function generateResourceList:TResourceList;
-var
-    cfgRes : TResourceList;
-    i,j : Integer;
-    t, t2 : shortstring;
-    si : TSprite;
-    res : TResourceList;
-
-begin
-
-    res.count := 0;
-
-    for i:= 0 to Pred(TeamsCount) do
-        with TeamsArray[i]^ do
-            begin
-                Str(i, t);
-                
-                res.files[res.count] := UserPathz[ptGraves] + '/' + GraveName;
-                res.files[res.count + 1] := UserPathz[ptForts] + '/' + FortName;
-                res.files[res.count + 2] := UserPathz[ptGraphics] + '/' + FortName;
-                res.files[res.count + 3] := UserPathz[ptFlags] + '/' + flag;
-
-                inc(res.count, 4);
-                
-            end;
-            
-    for si:= Low(TSprite) to High(TSprite) do
-    with SpritesData[si] do
-        begin
-            Str(si, t);
-            res.files[res.count] := UserPathz[Path] + '/' + FileName;
-            res.files[res.count + 1] := UserPathz[AltPath] + '/' + FileName;
-            inc(res.count, 2);
-
-        end;
-        
-    for i:= 0 to Pred(ClansCount) do
-    with CLansArray[i]^ do
-    begin
-        for j:= 0 to Pred(TeamsNumber) do
-        begin
-            with Teams[j]^ do
-            begin
-                Str(i, t);
-                Str(j, t2);
-                res.files[res.count] := UserPathz[ptForts] + '/' + FortName;
-                inc(res.count);
-
-            end;
-        end;
-    end;
-    
-    cfgRes := readThemeCfg();
-    
-    for i:= 0 to Pred(cfgRes.count) do
-    begin
-        res.files[res.count] := cfgRes.files[i];
-        inc(res.count);
-    end;
-    
-    res.files[res.count] := UserPathz[ptFlags] + '/cpu';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptFlags] + '/hedgewars';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptGraphics] + '/' + cHHFileName;
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptGraphics] + '/Girder';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptCurrTheme] + '/LandTex';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptCurrTheme] + '/LandBackTex';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptCurrTheme] + '/Girder';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptCurrTheme] + '/Border';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptMapCurrent] + '/mask';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptMapCurrent] + '/map';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptGraphics] + '/missions';
-    inc(res.count);
-    
-    res.files[res.count] := UserPathz[ptGraphics] + '/Progress';
-    inc(res.count);
-        
-    res.files[res.count] := UserPathz[ptGraves] + '/Statue';
-    inc(res.count);
-
-    res.files[res.count] := UserPathz[ptGraphics] + '/' + cCHFileName;
-    inc(res.count);
-
-    generateResourceList:=res;
-end;
-
-function readThemeCfg : TResourceList;
-var
-s,key : shortstring;
-f : TextFile;
-i: Integer;
-res : TResourceList;
-begin
-    s:=Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
-
-    Assign(f, s);
-    {$I-}
-
-    filemode := 0;
-    Reset(f);
-
-    res.count := 0;
-    
-    while not eof(f) do
-    begin
-    Readln(f, s);
-    
-    if Length(s) = 0 then
-        continue;
-    if s[1] = ';' then
-        continue;
-        
-    i:= Pos('=', s);
-    key:= Trim(Copy(s, 1, Pred(i)));
-    Delete(s, 1, i);
-    
-    if (key = 'object') or (key = 'spray') then
-    begin
-        i:=Pos(',', s);
-        
-        res.files[res.count] := Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i)));
-        res.files[res.count + 1] := Pathz[ptGraphics] + '/' + Trim(Copy(s, 1, Pred(i)));
-        inc(res.count, 2);
-        
-    end;
-    
-    end;
-
-    close(f);
-    {$I+}
-    
-    readThemeCfg := res;
-end;
-
-end.
--- a/hedgewars/uWorld.pas	Thu Jan 09 19:10:12 2014 +0100
+++ b/hedgewars/uWorld.pas	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 
 procedure DrawWorld(Lag: LongInt);
 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
-procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
+procedure ShowMission(caption, subcaption, mtext: PChar; icon, time : LongInt);
 procedure HideMission;
 procedure ShakeCamera(amount: LongInt);
 procedure InitCameraBorders;
@@ -216,7 +216,7 @@
 
 // if the string has been set, show it for (default timeframe) seconds
 if g <> '' then
-    ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0);
+    ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], PChar(g), 1, 0);
 
 cWaveWidth:= SpritesData[sprWater].Width;
 //cWaveHeight:= SpritesData[sprWater].Height;
@@ -412,6 +412,9 @@
     missionTex:= nil;
     FreeTexture(recTexture);
     recTexture:= nil;
+    FreeTexture(AmmoMenuTex);
+    AmmoMenuInvalidated:= true;
+    AmmoMenuTex:= nil;
 end;
 
 function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture;
@@ -855,12 +858,11 @@
         EndWater;
 {$ENDIF}
 
-        {$IFNDEF GL2}
-        glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required
-        {$ENDIF}
-        {$IFNDEF WEBGL}
+{$IFNDEF GL2}
+        // must not be Tint() as color array seems to stay active and color reset is required
+        glColor4ub($FF, $FF, $FF, $FF);
+{$ENDIF}
         glEnable(GL_TEXTURE_2D);
-        {$ENDIF}
     end;
 end;
 
@@ -1133,15 +1135,15 @@
         d:= -d;
     stereoDepth:= stereoDepth + d;
 
-    {$IFDEF GL2}
+{$IFDEF GL2}
     hglMatrixMode(MATRIX_PROJECTION);
     hglTranslatef(d, 0, 0);
     hglMatrixMode(MATRIX_MODELVIEW);
-    {$ELSE}
+{$ELSE}
     glMatrixMode(GL_PROJECTION);
     glTranslatef(d, 0, 0);
     glMatrixMode(GL_MODELVIEW);
-    {$ENDIF}
+{$ENDIF}
 {$ENDIF}
 end;
 
@@ -1153,15 +1155,15 @@
 {$ELSE}
     if rm = rmDefault then
         exit;
-    {$IFDEF GL2}
+{$IFDEF GL2}
     hglMatrixMode(MATRIX_PROJECTION);
     hglTranslatef(-stereoDepth, 0, 0);
     hglMatrixMode(MATRIX_MODELVIEW);
-    {$ELSE}
+{$ELSE}
     glMatrixMode(GL_PROJECTION);
     glTranslatef(-stereoDepth, 0, 0);
     glMatrixMode(GL_MODELVIEW);
-    {$ENDIF}
+{$ENDIF}
     cStereoDepth:= 0;
 {$ENDIF}
 end;
@@ -1228,7 +1230,7 @@
     glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required
     glEnable(GL_TEXTURE_2D);
 
-    // I'd still like to have things happen to the border when a wrap or bounce just occurred, based on a timer 
+    // I'd still like to have things happen to the border when a wrap or bounce just occurred, based on a timer
     if WorldEdge = weBounce then
         begin
         // could maybe alternate order of these on a bounce, or maybe drop the outer ones.
@@ -1330,7 +1332,7 @@
             for i:= 0 to cMaxHHIndex do
                 begin
                 inc(h, Hedgehogs[i].HealthBarHealth);
-                if (h < TeamHealthBarHealth) and (Hedgehogs[i].HealthBarHealth > 0) then 
+                if (h < TeamHealthBarHealth) and (Hedgehogs[i].HealthBarHealth > 0) then
                     DrawTexture(15 + h * TeamHealthBarWidth div TeamHealthBarHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture);
                 end;
 
@@ -1534,7 +1536,7 @@
             i:= Succ(Pred(ReadyTimeLeft) div 1000)
         else
             i:= Succ(Pred(TurnTimeLeft) div 1000);
-       
+
         if i>99 then
             t:= 112
         else if i>9 then
@@ -1962,7 +1964,7 @@
     WorldDx:= 1024;
 end;
 
-procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
+procedure ShowMission(caption, subcaption, mtext: PChar; icon, time : LongInt);
 var r: TSDL_Rect;
 begin
 r.w:= 32;
@@ -1977,13 +1979,13 @@
     begin
     r.x:= 0;
     r.y:= icon * 32;
-    missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r)
+    missionTex:= RenderHelpWindow(caption, subcaption, mtext, '', 0, MissionIcons, @r)
     end
 else
     begin
     r.x:= ((-icon - 1) shr 4) * 32;
     r.y:= ((-icon - 1) mod 16) * 32;
-    missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, SpritesData[sprAMAmmos].Surface, @r)
+    missionTex:= RenderHelpWindow(caption, subcaption, mtext, '', 0, SpritesData[sprAMAmmos].Surface, @r)
     end;
 end;
 
@@ -2110,6 +2112,8 @@
     WorldEnd[2].a:= 255;
     WorldEnd[3].a:= 255;
 
+    AmmoMenuTex:= nil;
+    AmmoMenuInvalidated:= true
 end;
 
 procedure freeModule;
--- a/hedgewars/videorec/avwrapper.c	Thu Jan 09 19:10:12 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,509 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdarg.h>
-#include "libavformat/avformat.h"
-#include "libavutil/mathematics.h"
-
-#ifndef AVIO_FLAG_WRITE
-#define AVIO_FLAG_WRITE AVIO_WRONLY
-#endif
-
-static AVFormatContext* g_pContainer;
-static AVOutputFormat* g_pFormat;
-static AVStream* g_pAStream;
-static AVStream* g_pVStream;
-static AVFrame* g_pAFrame;
-static AVFrame* g_pVFrame;
-static AVCodec* g_pACodec;
-static AVCodec* g_pVCodec;
-static AVCodecContext* g_pAudio;
-static AVCodecContext* g_pVideo;
-
-static int g_Width, g_Height;
-static uint32_t g_Frequency, g_Channels;
-static int g_VQuality;
-static AVRational g_Framerate;
-
-static FILE* g_pSoundFile;
-static int16_t* g_pSamples;
-static int g_NumSamples;
-
-
-#if LIBAVCODEC_VERSION_MAJOR < 54
-#define OUTBUFFER_SIZE 200000
-static uint8_t g_OutBuffer[OUTBUFFER_SIZE];
-#endif
-
-// pointer to function from hwengine (uUtils.pas)
-static void (*AddFileLogRaw)(const char* pString);
-
-static void FatalError(const char* pFmt, ...)
-{
-    char Buffer[1024];
-    va_list VaArgs;
-
-    va_start(VaArgs, pFmt);
-    vsnprintf(Buffer, 1024, pFmt, VaArgs);
-    va_end(VaArgs);
-
-    AddFileLogRaw("Error in av-wrapper: ");
-    AddFileLogRaw(Buffer);
-    AddFileLogRaw("\n");
-    exit(1);
-}
-
-// Function to be called from libav for logging.
-// Note: libav can call LogCallback from different threads
-// (there is mutex in AddFileLogRaw).
-static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs)
-{
-    char Buffer[1024];
-
-    vsnprintf(Buffer, 1024, pFmt, VaArgs);
-    AddFileLogRaw(Buffer);
-}
-
-static void Log(const char* pFmt, ...)
-{
-    char Buffer[1024];
-    va_list VaArgs;
-
-    va_start(VaArgs, pFmt);
-    vsnprintf(Buffer, 1024, pFmt, VaArgs);
-    va_end(VaArgs);
-
-    AddFileLogRaw(Buffer);
-}
-
-static void AddAudioStream()
-{
-#if LIBAVFORMAT_VERSION_MAJOR >= 53
-    g_pAStream = avformat_new_stream(g_pContainer, g_pACodec);
-#else
-    g_pAStream = av_new_stream(g_pContainer, 1);
-#endif
-    if(!g_pAStream)
-    {
-        Log("Could not allocate audio stream\n");
-        return;
-    }
-    g_pAStream->id = 1;
-
-    g_pAudio = g_pAStream->codec;
-
-    avcodec_get_context_defaults3(g_pAudio, g_pACodec);
-    g_pAudio->codec_id = g_pACodec->id;
-
-    // put parameters
-    g_pAudio->sample_fmt = AV_SAMPLE_FMT_S16;
-    g_pAudio->sample_rate = g_Frequency;
-    g_pAudio->channels = g_Channels;
-
-    // set quality
-    g_pAudio->bit_rate = 160000;
-
-    // for codecs that support variable bitrate use it, it should be better
-    g_pAudio->flags |= CODEC_FLAG_QSCALE;
-    g_pAudio->global_quality = 1*FF_QP2LAMBDA;
-
-    // some formats want stream headers to be separate
-    if (g_pFormat->flags & AVFMT_GLOBALHEADER)
-        g_pAudio->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
-    // open it
-#if LIBAVCODEC_VERSION_MAJOR >= 53
-    if (avcodec_open2(g_pAudio, g_pACodec, NULL) < 0)
-#else
-    if (avcodec_open(g_pAudio, g_pACodec) < 0)
-#endif
-    {
-        Log("Could not open audio codec %s\n", g_pACodec->long_name);
-        return;
-    }
-
-#if LIBAVCODEC_VERSION_MAJOR >= 54
-    if (g_pACodec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
-#else
-    if (g_pAudio->frame_size == 0)
-#endif
-        g_NumSamples = 4096;
-    else
-        g_NumSamples = g_pAudio->frame_size;
-    g_pSamples = (int16_t*)av_malloc(g_NumSamples*g_Channels*sizeof(int16_t));
-    g_pAFrame = avcodec_alloc_frame();
-    if (!g_pAFrame)
-    {
-        Log("Could not allocate frame\n");
-        return;
-    }
-}
-
-// returns non-zero if there is more sound
-static int WriteAudioFrame()
-{
-    if (!g_pAStream)
-        return 0;
-
-    AVPacket Packet = { 0 };
-    av_init_packet(&Packet);
-
-    int NumSamples = fread(g_pSamples, 2*g_Channels, g_NumSamples, g_pSoundFile);
-
-#if LIBAVCODEC_VERSION_MAJOR >= 53
-    AVFrame* pFrame = NULL;
-    if (NumSamples > 0)
-    {
-        g_pAFrame->nb_samples = NumSamples;
-        avcodec_fill_audio_frame(g_pAFrame, g_Channels, AV_SAMPLE_FMT_S16,
-                                 (uint8_t*)g_pSamples, NumSamples*2*g_Channels, 1);
-        pFrame = g_pAFrame;
-    }
-    // when NumSamples == 0 we still need to call encode_audio2 to flush
-    int got_packet;
-    if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet) != 0)
-        FatalError("avcodec_encode_audio2 failed");
-    if (!got_packet)
-        return 0;
-#else
-    if (NumSamples == 0)
-        return 0;
-    int BufferSize = OUTBUFFER_SIZE;
-    if (g_pAudio->frame_size == 0)
-        BufferSize = NumSamples*g_Channels*2;
-    Packet.size = avcodec_encode_audio(g_pAudio, g_OutBuffer, BufferSize, g_pSamples);
-    if (Packet.size == 0)
-        return 1;
-    if (g_pAudio->coded_frame && g_pAudio->coded_frame->pts != AV_NOPTS_VALUE)
-        Packet.pts = av_rescale_q(g_pAudio->coded_frame->pts, g_pAudio->time_base, g_pAStream->time_base);
-    Packet.flags |= AV_PKT_FLAG_KEY;
-    Packet.data = g_OutBuffer;
-#endif
-
-    // Write the compressed frame to the media file.
-    Packet.stream_index = g_pAStream->index;
-    if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) 
-        FatalError("Error while writing audio frame");
-    return 1;
-}
-
-// add a video output stream
-static void AddVideoStream()
-{
-#if LIBAVFORMAT_VERSION_MAJOR >= 53
-    g_pVStream = avformat_new_stream(g_pContainer, g_pVCodec);
-#else
-    g_pVStream = av_new_stream(g_pContainer, 0);
-#endif
-    if (!g_pVStream)
-        FatalError("Could not allocate video stream");
-
-    g_pVideo = g_pVStream->codec;
-
-    avcodec_get_context_defaults3(g_pVideo, g_pVCodec);
-    g_pVideo->codec_id = g_pVCodec->id;
-
-    // put parameters
-    // resolution must be a multiple of two
-    g_pVideo->width  = g_Width  & ~1; // make even (dimensions should be even)
-    g_pVideo->height = g_Height & ~1; // make even
-    /* time base: this is the fundamental unit of time (in seconds) in terms
-       of which frame timestamps are represented. for fixed-fps content,
-       timebase should be 1/framerate and timestamp increments should be
-       identically 1. */
-    g_pVideo->time_base.den = g_Framerate.num;
-    g_pVideo->time_base.num = g_Framerate.den;
-    //g_pVideo->gop_size = 12; /* emit one intra frame every twelve frames at most */
-    g_pVideo->pix_fmt = PIX_FMT_YUV420P;
-
-    // set quality
-    if (g_VQuality > 100)
-        g_pVideo->bit_rate = g_VQuality;
-    else
-    {
-        g_pVideo->flags |= CODEC_FLAG_QSCALE;
-        g_pVideo->global_quality = g_VQuality*FF_QP2LAMBDA;
-    }
-
-    // some formats want stream headers to be separate
-    if (g_pFormat->flags & AVFMT_GLOBALHEADER)
-        g_pVideo->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
-#if LIBAVCODEC_VERSION_MAJOR < 53
-    // for some versions of ffmpeg x264 options must be set explicitly
-    if (strcmp(g_pVCodec->name, "libx264") == 0)
-    {
-        g_pVideo->coder_type = FF_CODER_TYPE_AC;
-        g_pVideo->flags |= CODEC_FLAG_LOOP_FILTER;
-        g_pVideo->crf = 23;
-        g_pVideo->thread_count = 3;
-        g_pVideo->me_cmp = FF_CMP_CHROMA;
-        g_pVideo->partitions = X264_PART_I8X8 | X264_PART_I4X4 | X264_PART_P8X8 | X264_PART_B8X8;
-        g_pVideo->me_method = ME_HEX;
-        g_pVideo->me_subpel_quality = 7;
-        g_pVideo->me_range = 16;
-        g_pVideo->gop_size = 250;
-        g_pVideo->keyint_min = 25;
-        g_pVideo->scenechange_threshold = 40;
-        g_pVideo->i_quant_factor = 0.71;
-        g_pVideo->b_frame_strategy = 1;
-        g_pVideo->qcompress = 0.6;
-        g_pVideo->qmin = 10;
-        g_pVideo->qmax = 51;
-        g_pVideo->max_qdiff = 4;
-        g_pVideo->max_b_frames = 3;
-        g_pVideo->refs = 3;
-        g_pVideo->directpred = 1;
-        g_pVideo->trellis = 1;
-        g_pVideo->flags2 = CODEC_FLAG2_BPYRAMID | CODEC_FLAG2_MIXED_REFS | CODEC_FLAG2_WPRED | CODEC_FLAG2_8X8DCT | CODEC_FLAG2_FASTPSKIP;
-        g_pVideo->weighted_p_pred = 2;
-    }
-#endif
-
-    // open the codec
-#if LIBAVCODEC_VERSION_MAJOR >= 53
-    AVDictionary* pDict = NULL;
-    if (strcmp(g_pVCodec->name, "libx264") == 0)
-        av_dict_set(&pDict, "preset", "medium", 0);
-
-    if (avcodec_open2(g_pVideo, g_pVCodec, &pDict) < 0)
-#else
-    if (avcodec_open(g_pVideo, g_pVCodec) < 0)
-#endif
-        FatalError("Could not open video codec %s", g_pVCodec->long_name);
-
-    g_pVFrame = avcodec_alloc_frame();
-    if (!g_pVFrame)
-        FatalError("Could not allocate frame");
-
-    g_pVFrame->linesize[0] = g_Width;
-    g_pVFrame->linesize[1] = g_Width/2;
-    g_pVFrame->linesize[2] = g_Width/2;
-    g_pVFrame->linesize[3] = 0;
-}
-
-static int WriteFrame(AVFrame* pFrame)
-{
-    double AudioTime, VideoTime;
-
-    // write interleaved audio frame
-    if (g_pAStream)
-    {
-        VideoTime = (double)g_pVStream->pts.val*g_pVStream->time_base.num/g_pVStream->time_base.den;
-        do
-            AudioTime = (double)g_pAStream->pts.val*g_pAStream->time_base.num/g_pAStream->time_base.den;
-        while (AudioTime < VideoTime && WriteAudioFrame());
-    }
-    
-    if (!g_pVStream)
-        return 0;
-
-    AVPacket Packet;
-    av_init_packet(&Packet);
-    Packet.data = NULL;
-    Packet.size = 0;
-
-    g_pVFrame->pts++;
-    if (g_pFormat->flags & AVFMT_RAWPICTURE)
-    {
-        /* raw video case. The API will change slightly in the near
-           future for that. */
-        Packet.flags |= AV_PKT_FLAG_KEY;
-        Packet.stream_index = g_pVStream->index;
-        Packet.data = (uint8_t*)pFrame;
-        Packet.size = sizeof(AVPicture);
-
-        if (av_interleaved_write_frame(g_pContainer, &Packet) != 0)
-            FatalError("Error while writing video frame");
-        return 0;
-    }
-    else
-    {
-#if LIBAVCODEC_VERSION_MAJOR >= 54
-        int got_packet;
-        if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet) < 0)
-            FatalError("avcodec_encode_video2 failed");
-        if (!got_packet)
-            return 0;
-
-        if (Packet.pts != AV_NOPTS_VALUE)
-            Packet.pts = av_rescale_q(Packet.pts, g_pVideo->time_base, g_pVStream->time_base);
-        if (Packet.dts != AV_NOPTS_VALUE)
-            Packet.dts = av_rescale_q(Packet.dts, g_pVideo->time_base, g_pVStream->time_base);
-#else 
-        Packet.size = avcodec_encode_video(g_pVideo, g_OutBuffer, OUTBUFFER_SIZE, pFrame);
-        if (Packet.size < 0)
-            FatalError("avcodec_encode_video failed");
-        if (Packet.size == 0)
-            return 0;
-
-        if( g_pVideo->coded_frame->pts != AV_NOPTS_VALUE)
-            Packet.pts = av_rescale_q(g_pVideo->coded_frame->pts, g_pVideo->time_base, g_pVStream->time_base);
-        if( g_pVideo->coded_frame->key_frame )
-            Packet.flags |= AV_PKT_FLAG_KEY;
-        Packet.data = g_OutBuffer;
-#endif
-        // write the compressed frame in the media file
-        Packet.stream_index = g_pVStream->index;
-        if (av_interleaved_write_frame(g_pContainer, &Packet) != 0)
-            FatalError("Error while writing video frame");
-            
-        return 1;
-    }
-}
-
-void AVWrapper_WriteFrame(uint8_t* pY, uint8_t* pCb, uint8_t* pCr)
-{
-    g_pVFrame->data[0] = pY;
-    g_pVFrame->data[1] = pCb;
-    g_pVFrame->data[2] = pCr;
-    WriteFrame(g_pVFrame);
-}
-
-void AVWrapper_Init(
-         void (*pAddFileLogRaw)(const char*),
-         const char* pFilename,
-         const char* pDesc,
-         const char* pSoundFile,
-         const char* pFormatName,
-         const char* pVCodecName,
-         const char* pACodecName,
-         int Width, int Height,
-         int FramerateNum, int FramerateDen,
-         int VQuality)
-{    
-    AddFileLogRaw = pAddFileLogRaw;
-    av_log_set_callback( &LogCallback );
-
-    g_Width  = Width;
-    g_Height = Height;
-    g_Framerate.num = FramerateNum;
-    g_Framerate.den = FramerateDen;
-    g_VQuality = VQuality;
-
-    // initialize libav and register all codecs and formats
-    av_register_all();
-
-    // find format
-    g_pFormat = av_guess_format(pFormatName, NULL, NULL);
-    if (!g_pFormat)
-        FatalError("Format \"%s\" was not found", pFormatName);
-
-    // allocate the output media context
-    g_pContainer = avformat_alloc_context();
-    if (!g_pContainer)
-        FatalError("Could not allocate output context");
-
-    g_pContainer->oformat = g_pFormat;
-
-    // store description of file
-    av_dict_set(&g_pContainer->metadata, "comment", pDesc, 0);
-
-    // append extesnion to filename
-    char ext[16];
-    strncpy(ext, g_pFormat->extensions, 16);
-    ext[15] = 0;
-    ext[strcspn(ext,",")] = 0;
-    snprintf(g_pContainer->filename, sizeof(g_pContainer->filename), "%s.%s", pFilename, ext);
-
-    // find codecs
-    g_pVCodec = avcodec_find_encoder_by_name(pVCodecName);
-    g_pACodec = avcodec_find_encoder_by_name(pACodecName);
-
-    // add audio and video stream to container
-    g_pVStream = NULL;
-    g_pAStream = NULL;
-
-    if (g_pVCodec)
-        AddVideoStream();
-    else
-        Log("Video codec \"%s\" was not found; video will be ignored.\n", pVCodecName);
-
-    if (g_pACodec)
-    {
-        g_pSoundFile = fopen(pSoundFile, "rb");
-        if (g_pSoundFile)
-        {
-            fread(&g_Frequency, 4, 1, g_pSoundFile);
-            fread(&g_Channels, 4, 1, g_pSoundFile);
-            AddAudioStream();
-        }
-        else
-            Log("Could not open %s\n", pSoundFile);
-    }
-    else
-        Log("Audio codec \"%s\" was not found; audio will be ignored.\n", pACodecName);
-
-    if (!g_pAStream && !g_pVStream)
-        FatalError("No video, no audio, aborting...");
-
-    // write format info to log
-    av_dump_format(g_pContainer, 0, g_pContainer->filename, 1);
-
-    // open the output file, if needed
-    if (!(g_pFormat->flags & AVFMT_NOFILE))
-    {
-        if (avio_open(&g_pContainer->pb, g_pContainer->filename, AVIO_FLAG_WRITE) < 0)
-            FatalError("Could not open output file (%s)", g_pContainer->filename);
-    }
-
-    // write the stream header, if any
-    avformat_write_header(g_pContainer, NULL);
-
-    g_pVFrame->pts = -1;
-}
-
-void AVWrapper_Close()
-{
-    // output buffered frames
-    if (g_pVCodec->capabilities & CODEC_CAP_DELAY)
-        while( WriteFrame(NULL) );
-    // output any remaining audio
-    while( WriteAudioFrame() );
-
-    // write the trailer, if any.
-    av_write_trailer(g_pContainer);
-
-    // close the output file
-    if (!(g_pFormat->flags & AVFMT_NOFILE))
-        avio_close(g_pContainer->pb);
-
-    // free everything
-    if (g_pVStream)
-    {
-        avcodec_close(g_pVideo);
-        av_free(g_pVideo);
-        av_free(g_pVStream);
-        av_free(g_pVFrame);
-    }
-    if (g_pAStream)
-    {
-        avcodec_close(g_pAudio);
-        av_free(g_pAudio);
-        av_free(g_pAStream);
-        av_free(g_pAFrame);
-        av_free(g_pSamples);
-        fclose(g_pSoundFile);
-    }
-
-    av_free(g_pContainer);
-}
--- a/misc/liblua/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/liblua/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,5 @@
 #this file is included only when system Lua library is not found
 
-#TODO: when BUILD_ENGINE_C=1 it should use clang here too
-
 file(GLOB lua_src *.c *.h)
 
 if(WIN32)
--- a/misc/liblua/lauxlib.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/liblua/lauxlib.c	Tue Jan 21 22:38:13 2014 +0100
@@ -25,12 +25,12 @@
 #include "lauxlib.h"
 
 
-#define FREELIST_REF	0	/* free list of references */
+#define FREELIST_REF    0   /* free list of references */
 
 
 /* convert a stack index to positive */
-#define abs_index(L, i)		((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
-					lua_gettop(L) + (i) + 1)
+#define abs_index(L, i)     ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
+                    lua_gettop(L) + (i) + 1)
 
 
 /*
@@ -389,10 +389,10 @@
 */
 
 
-#define bufflen(B)	((B)->p - (B)->buffer)
-#define bufffree(B)	((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
+#define bufflen(B)  ((B)->p - (B)->buffer)
+#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
 
-#define LIMIT	(LUA_MINSTACK/2)
+#define LIMIT   (LUA_MINSTACK/2)
 
 
 static int emptybuffer (luaL_Buffer *B) {
--- a/misc/libphyslayer/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/libphyslayer/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -6,6 +6,7 @@
 
 
 set(PHYSLAYER_SRCS
+    physfscompat.c
     physfsrwops.c
     physfslualoader.c
     hwpacksmounter.c
--- a/misc/libphyslayer/hwpacksmounter.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/libphyslayer/hwpacksmounter.h	Tue Jan 21 22:38:13 2014 +0100
@@ -2,10 +2,8 @@
 #define HEDGEWARS_PACKAGES_MOUNTER_H
 
 #include "physfs.h"
-
-#ifndef STRINIT
+#include "physfscompat.h"
 #include "lua.h"
-#endif
 
 #ifdef __cplusplus
 extern "C" {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/libphyslayer/physfscompat.c	Tue Jan 21 22:38:13 2014 +0100
@@ -0,0 +1,73 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "physfscompat.h"
+
+#ifdef HW_PHYSFS_COMPAT
+
+PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat)
+{
+    PHYSFS_File * handle;
+
+    if (PHYSFS_exists(fname))
+    {
+        handle = PHYSFS_openRead(fname);
+        if (handle)
+        {
+            stat->filesize = PHYSFS_fileLength(handle);
+            PHYSFS_close(handle);
+            handle = 0;
+        }
+        else
+            stat->filesize = -1;
+
+        stat->modtime = PHYSFS_getLastModTime(fname);
+        stat->createtime = -1;
+        stat->accesstime = -1;
+
+        if (PHYSFS_isSymbolicLink(fname))
+            stat->filetype = PHYSFS_FILETYPE_SYMLINK;
+        else if (PHYSFS_isDirectory(fname))
+            stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
+        else stat->filetype = PHYSFS_FILETYPE_REGULAR;
+
+        stat->readonly = 0; /* not supported */
+
+        /* success */
+        return 1;
+    }
+
+    /* does not exist, can't stat */
+    return 0;
+}
+
+PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer,
+                                           PHYSFS_uint64 len)
+{
+    return PHYSFS_read(handle, buffer, 1, len);
+}
+
+
+PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle,
+                                            const void *buffer,
+                                            PHYSFS_uint64 len)
+{
+    return PHYSFS_write(handle, buffer, 1, len);
+}
+
+#endif /* HW_PHYSFS_COMPAT */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/libphyslayer/physfscompat.h	Tue Jan 21 22:38:13 2014 +0100
@@ -0,0 +1,71 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef _HEDGEWARS_PHYSFSCOMPAT_C_
+#define _HEDGEWARS_PHYSFSCOMPAT_C_
+
+#include "physfs.h"
+
+#if PHYSFS_VER_MAJOR == 2
+#if PHYSFS_VER_MINOR == 0
+
+#define HW_PHYSFS_COMPAT
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PHYSFS_DECL __EXPORT__
+
+typedef enum PHYSFS_FileType
+{
+	PHYSFS_FILETYPE_REGULAR,
+	PHYSFS_FILETYPE_DIRECTORY,
+	PHYSFS_FILETYPE_SYMLINK,
+	PHYSFS_FILETYPE_OTHER
+} PHYSFS_FileType;
+
+typedef struct PHYSFS_Stat
+{
+	PHYSFS_sint64 filesize;
+	PHYSFS_sint64 modtime;
+	PHYSFS_sint64 createtime;
+	PHYSFS_sint64 accesstime;
+	PHYSFS_FileType filetype;
+	int readonly;
+} PHYSFS_Stat;
+
+PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat);
+
+PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer,
+                                           PHYSFS_uint64 len);
+
+
+PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle,
+                                            const void *buffer,
+                                            PHYSFS_uint64 len);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PHYSFS_VER_MAJOR == 2 */
+#endif /* PHYSFS_VER_MINOR == 0 */
+
+#endif /* _HEDGEWARS_PHYSFSCOMPAT_C_ */
--- a/misc/libphyslayer/physfslualoader.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/libphyslayer/physfslualoader.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,6 +1,8 @@
 #include "lua.h"
 #include "physfs.h"
 
+#include "physfscompat.h"
+
 #define BUFSIZE 1024
 
 void *physfsReaderBuffer;
--- a/misc/libphyslayer/physfsrwops.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/misc/libphyslayer/physfsrwops.h	Tue Jan 21 22:38:13 2014 +0100
@@ -26,6 +26,8 @@
 #include "physfs.h"
 #include "SDL.h"
 
+#include "physfscompat.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
--- a/project_files/Android-build/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/Android-build/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -27,7 +27,7 @@
 
 if(IS_DIRECTORY "${ANDROID_NDK}")
     message(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK})
-else ()
+else()
     message(FATAL_ERROR "Couldn't detect the Android NDK directory")
 endif()
 
@@ -40,24 +40,24 @@
 
 if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}")
     message(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}")
-else ()
+else()
     message(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}")
 endif()
 
-if(NOT ANDROID_SDK)#Check if its defined at the cmdline
+if(NOT ANDROID_SDK) #Check if its defined at the cmdline
     find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path
     get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
     get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
     set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE)
 endif()
 
-if( IS_DIRECTORY "${ANDROID_SDK}")
+if(IS_DIRECTORY "${ANDROID_SDK}")
     message(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK})
-else ()
+else()
     message(FATAL_ERROR "Couldn't detect the Android SDK directory")
 endif()
 
-if( NOT FPC_DIR)
+if(NOT FPC_DIR)
     find_program(FPC_DIR ppcrossarm)
     get_filename_component(FPC_DIR "${FPC_DIR}" PATH)
     if(IS_DIRECTORY "${FPC_DIR}")
@@ -65,9 +65,9 @@
     endif()
 endif()
 
-if( IS_DIRECTORY "${FPC_DIR}")
-    message(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}")
-else ()
+if(IS_DIRECTORY "${FPC_DIR}")
+    message(STATUS "Detected the FreePascal directory at: ${FPC_DIR}")
+else()
     message(FATAL_ERROR "Couldn't detect the FreePascal directory")
 endif()
 
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java	Tue Jan 21 22:38:13 2014 +0100
@@ -2,7 +2,7 @@
  * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
  * Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com>
  * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
--- a/project_files/frontlib/hwconsts.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/hwconsts.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,118 +1,118 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
- * Copyright (c) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-/**
- * This file contains important constants which might need to be changed to adapt to
- * changes in the engine or protocols.
- *
- * It also contains getter functions for some constants (in particular for constants
- * that are important for the layout of data structures), so that client code can
- * query the constants that the library was built with.
- */
-
-#ifndef HWCONSTS_H_
-#define HWCONSTS_H_
-
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdbool.h>
-
-#define HEDGEHOGS_PER_TEAM 8
-#define DEFAULT_HEDGEHOG_COUNT 4
-#define DEFAULT_COLOR_INDEX 0
-
-#define NETGAME_DEFAULT_PORT 46631
-#define PROTOCOL_VERSION 42
-#define MIN_SERVER_VERSION 1
-
-//! Used for sending scripts to the engine
-#define MULTIPLAYER_SCRIPT_PATH "Scripts/Multiplayer/"
-
-#define WEAPONS_COUNT 56
-
-// TODO allow frontend to override these?
-/*! A merge of mikade/bugq colours w/ a bit of channel feedback */
-#define HW_TEAMCOLOR_ARRAY  { UINT32_C(0xffff0204), /*! red    */ \
-                              UINT32_C(0xff4980c1), /*! blue   */ \
-                              UINT32_C(0xff1de6ba), /*! teal   */ \
-                              UINT32_C(0xffb541ef), /*! purple */ \
-                              UINT32_C(0xffe55bb0), /*! pink   */ \
-                              UINT32_C(0xff20bf00), /*! green  */ \
-                              UINT32_C(0xfffe8b0e), /*! orange */ \
-                              UINT32_C(0xff5f3605), /*! brown  */ \
-                              UINT32_C(0xffffff01), /*! yellow */ \
-                              /*! add new colors here */ \
-                              0 } /*! Keep this 0 at the end */
-
-extern const size_t flib_teamcolor_count;
-extern const uint32_t flib_teamcolors[];
-
-/**
- * Returns the team color (ARGB) corresponding to the color index (0 if index out of bounds)
- */
-uint32_t flib_get_teamcolor(int colorIndex);
-
-/**
- * Returns the number of team colors (i.e. the length of the flib_teamcolors array)
- */
-int flib_get_teamcolor_count();
-
-/**
- * Returns the HEDGEHOGS_PER_TEAM constant
- */
-int flib_get_hedgehogs_per_team();
-
-/**
- * Returns the WEAPONS_COUNT constant
- */
-int flib_get_weapons_count();
-
-/*!
- * These structs define the meaning of values in the flib_scheme struct, i.e. their correspondence to
- * ini settings, engine commands and positions in the network protocol (the last is encoded in the
- * order of settings/mods).
- */
-typedef struct {
-    const char *name;               //!< A name identifying this setting (used as key in the schemes file)
-    const char *engineCommand;      //!< The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting)
-    const bool maxMeansInfinity;    //!< If true, send a very high number to the engine if the setting is equal to its maximum
-    const bool times1000;           //!< If true (for time-based settings), multiply the setting by 1000 before sending it to the engine.
-    const int min;                  //!< The smallest allowed value
-    const int max;                  //!< The highest allowed value
-    const int def;                  //!< The default value
-} flib_metascheme_setting;
-
-typedef struct {
-    const char *name;               //!< A name identifying this mod (used as key in the schemes file)
-    const int bitmaskIndex;         //!< Mods are sent to the engine in a single integer, this field describes which bit of that integer is used
-                                    //! for this particular mod.
-} flib_metascheme_mod;
-
-typedef struct {
-    const int settingCount;
-    const int modCount;
-    const flib_metascheme_setting *settings;
-    const flib_metascheme_mod *mods;
-} flib_metascheme;
-
-extern const flib_metascheme flib_meta;
-
-const flib_metascheme *flib_get_metascheme();
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/**
+ * This file contains important constants which might need to be changed to adapt to
+ * changes in the engine or protocols.
+ *
+ * It also contains getter functions for some constants (in particular for constants
+ * that are important for the layout of data structures), so that client code can
+ * query the constants that the library was built with.
+ */
+
+#ifndef HWCONSTS_H_
+#define HWCONSTS_H_
+
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+#define HEDGEHOGS_PER_TEAM 8
+#define DEFAULT_HEDGEHOG_COUNT 4
+#define DEFAULT_COLOR_INDEX 0
+
+#define NETGAME_DEFAULT_PORT 46631
+#define PROTOCOL_VERSION 42
+#define MIN_SERVER_VERSION 1
+
+//! Used for sending scripts to the engine
+#define MULTIPLAYER_SCRIPT_PATH "Scripts/Multiplayer/"
+
+#define WEAPONS_COUNT 56
+
+// TODO allow frontend to override these?
+/*! A merge of mikade/bugq colours w/ a bit of channel feedback */
+#define HW_TEAMCOLOR_ARRAY  { UINT32_C(0xffff0204), /*! red    */ \
+                              UINT32_C(0xff4980c1), /*! blue   */ \
+                              UINT32_C(0xff1de6ba), /*! teal   */ \
+                              UINT32_C(0xffb541ef), /*! purple */ \
+                              UINT32_C(0xffe55bb0), /*! pink   */ \
+                              UINT32_C(0xff20bf00), /*! green  */ \
+                              UINT32_C(0xfffe8b0e), /*! orange */ \
+                              UINT32_C(0xff5f3605), /*! brown  */ \
+                              UINT32_C(0xffffff01), /*! yellow */ \
+                              /*! add new colors here */ \
+                              0 } /*! Keep this 0 at the end */
+
+extern const size_t flib_teamcolor_count;
+extern const uint32_t flib_teamcolors[];
+
+/**
+ * Returns the team color (ARGB) corresponding to the color index (0 if index out of bounds)
+ */
+uint32_t flib_get_teamcolor(int colorIndex);
+
+/**
+ * Returns the number of team colors (i.e. the length of the flib_teamcolors array)
+ */
+int flib_get_teamcolor_count();
+
+/**
+ * Returns the HEDGEHOGS_PER_TEAM constant
+ */
+int flib_get_hedgehogs_per_team();
+
+/**
+ * Returns the WEAPONS_COUNT constant
+ */
+int flib_get_weapons_count();
+
+/*!
+ * These structs define the meaning of values in the flib_scheme struct, i.e. their correspondence to
+ * ini settings, engine commands and positions in the network protocol (the last is encoded in the
+ * order of settings/mods).
+ */
+typedef struct {
+    const char *name;				//!< A name identifying this setting (used as key in the schemes file)
+    const char *engineCommand;		//!< The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting)
+    const bool maxMeansInfinity;	//!< If true, send a very high number to the engine if the setting is equal to its maximum
+    const bool times1000;			//!< If true (for time-based settings), multiply the setting by 1000 before sending it to the engine.
+    const int min;					//!< The smallest allowed value
+    const int max;					//!< The highest allowed value
+    const int def;					//!< The default value
+} flib_metascheme_setting;
+
+typedef struct {
+    const char *name;				//!< A name identifying this mod (used as key in the schemes file)
+    const int bitmaskIndex;			//!< Mods are sent to the engine in a single integer, this field describes which bit of that integer is used
+    								//! for this particular mod.
+} flib_metascheme_mod;
+
+typedef struct {
+	const int settingCount;
+	const int modCount;
+	const flib_metascheme_setting *settings;
+	const flib_metascheme_mod *mods;
+} flib_metascheme;
+
+extern const flib_metascheme flib_meta;
+
+const flib_metascheme *flib_get_metascheme();
+
+#endif
--- a/project_files/frontlib/md5/md5.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/md5/md5.h	Tue Jan 21 22:38:13 2014 +0100
@@ -27,7 +27,7 @@
 
   This code implements the MD5 Algorithm defined in RFC 1321, whose
   text is available at
-    http://www.ietf.org/rfc/rfc1321.txt
+	http://www.ietf.org/rfc/rfc1321.txt
   The code is derived from the text of the RFC, including the test suite
   (section A.5) but excluding the rest of Appendix A.  It does not include
   any code or documentation that is identified in the RFC as being
@@ -38,12 +38,12 @@
   that follows (in reverse chronological order):
 
   2002-04-13 lpd Removed support for non-ANSI compilers; removed
-    references to Ghostscript; clarified derivation from RFC 1321;
-    now handles byte order either statically or dynamically.
+	references to Ghostscript; clarified derivation from RFC 1321;
+	now handles byte order either statically or dynamically.
   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
-    added conditionalization for C++ compilation from Martin
-    Purschke <purschke@bnl.gov>.
+	added conditionalization for C++ compilation from Martin
+	Purschke <purschke@bnl.gov>.
   1999-05-03 lpd Original version.
  */
 
@@ -65,13 +65,13 @@
 
 /*! Define the state of the MD5 Algorithm. */
 typedef struct md5_state_s {
-    md5_word_t count[2];    /*! message length in bits, lsw first */
-    md5_word_t abcd[4];     /*! digest buffer */
-    md5_byte_t buf[64];     /*! accumulate block */
+    md5_word_t count[2];	/*! message length in bits, lsw first */
+    md5_word_t abcd[4];		/*! digest buffer */
+    md5_byte_t buf[64];		/*! accumulate block */
 } md5_state_t;
 
 #ifdef __cplusplus
-extern "C"
+extern "C" 
 {
 #endif
 
--- a/project_files/frontlib/model/gamesetup.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/model/gamesetup.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,47 +1,47 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/**
- * A complete game configuration that contains all settings the engine needs to start a
- * local or networked game.
- */
-
-#ifndef MODEL_GAMESETUP_H_
-#define MODEL_GAMESETUP_H_
-
-#include "scheme.h"
-#include "weapon.h"
-#include "map.h"
-#include "teamlist.h"
-
-typedef struct {
-    char *style;                //!< e.g. "Capture the Flag"
-    flib_scheme *gamescheme;
-    flib_map *map;
-    flib_teamlist *teamlist;
-} flib_gamesetup;
-
-void flib_gamesetup_destroy(flib_gamesetup *gamesetup);
-
-/**
- * Deep-copy of the flib_gamesetup.
- */
-flib_gamesetup *flib_gamesetup_copy(const flib_gamesetup *gamesetup);
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * A complete game configuration that contains all settings the engine needs to start a
+ * local or networked game.
+ */
+
+#ifndef MODEL_GAMESETUP_H_
+#define MODEL_GAMESETUP_H_
+
+#include "scheme.h"
+#include "weapon.h"
+#include "map.h"
+#include "teamlist.h"
+
+typedef struct {
+    char *style;				//!< e.g. "Capture the Flag"
+    flib_scheme *gamescheme;
+    flib_map *map;
+	flib_teamlist *teamlist;
+} flib_gamesetup;
+
+void flib_gamesetup_destroy(flib_gamesetup *gamesetup);
+
+/**
+ * Deep-copy of the flib_gamesetup.
+ */
+flib_gamesetup *flib_gamesetup_copy(const flib_gamesetup *gamesetup);
+
+#endif
--- a/project_files/frontlib/model/map.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/model/map.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,114 +1,114 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#ifndef MODEL_MAP_H_
-#define MODEL_MAP_H_
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#define MAPGEN_REGULAR 0
-#define MAPGEN_MAZE 1
-#define MAPGEN_DRAWN 2
-#define MAPGEN_NAMED 3
-
-#define TEMPLATEFILTER_ALL 0
-#define TEMPLATEFILTER_SMALL 1
-#define TEMPLATEFILTER_MEDIUM 2
-#define TEMPLATEFILTER_LARGE 3
-#define TEMPLATEFILTER_CAVERN 4
-#define TEMPLATEFILTER_WACKY 5
-
-#define MAZE_SIZE_SMALL_TUNNELS 0
-#define MAZE_SIZE_MEDIUM_TUNNELS 1
-#define MAZE_SIZE_LARGE_TUNNELS 2
-#define MAZE_SIZE_SMALL_ISLANDS 3
-#define MAZE_SIZE_MEDIUM_ISLANDS 4
-#define MAZE_SIZE_LARGE_ISLANDS 5
-
-/**
- * Data structure for defining a map. This contains the whole recipe to
- * exactly recreate a particular map.
- *
- * The required fields depend on the map generator, see the comments
- * at the struct for details.
- */
-typedef struct {
-    int mapgen;             //!< Always one of the MAPGEN_ constants
-    char *name;             //!< The name of the map for MAPGEN_NAMED (e.g. "Cogs"), otherwise one of "+rnd+", "+maze+" or "+drawn+".
-    char *seed;             //!< Used for all maps. This is a random seed for all (non-AI) entropy in the round. Typically a random UUID, but can be any string.
-    char *theme;            //!< Used for all maps. This is the name of a directory in Data/Themes (e.g. "Beach")
-    uint8_t *drawData;      //!< Used for MAPGEN_DRAWN
-    size_t drawDataSize;    //!< Used for MAPGEN_DRAWN
-    int templateFilter;     //!< Used for MAPGEN_REGULAR. One of the TEMPLATEFILTER_xxx constants.
-    int mazeSize;           //!< Used for MAPGEN_MAZE. One of the MAZE_SIZE_xxx constants.
-} flib_map;
-
-/**
- * Create a generated map. theme should be the name of a
- * directory in "Themes" and templateFilter should be one of the
- * TEMPLATEFILTER_* constants, but this is not checked before
- * passing it to the engine.
- *
- * Use flib_map_destroy to free the returned object.
- * No NULL parameters allowed, returns NULL on failure.
- */
-flib_map *flib_map_create_regular(const char *seed, const char *theme, int templateFilter);
-
-/**
- * Create a generated maze-type map. theme should be the name of a
- * directory in "Themes" and mazeSize should be one of the
- * MAZE_SIZE_* constants, but this is not checked before
- * passing it to the engine.
- *
- * Use flib_map_destroy to free the returned object.
- * No NULL parameters allowed, returns NULL on failure.
- */
-flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize);
-
-/**
- * Create a map from the Maps-Directory. name should be the name of a
- * directory in "Maps", but this is not checked before
- * passing it to the engine. If this is a mission, the corresponding
- * script is used automatically.
- *
- * Use flib_map_destroy to free the returned object.
- * No NULL parameters allowed, returns NULL on failure.
- */
-flib_map *flib_map_create_named(const char *seed, const char *name);
-
-/**
- * Create a hand-drawn map. Use flib_map_destroy to free the returned object.
- * No NULL parameters allowed, returns NULL on failure.
- */
-flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize);
-
-/**
- * Create a deep copy of the map. Returns NULL on failure or if NULL was passed.
- */
-flib_map *flib_map_copy(const flib_map *map);
-
-/**
- * Decrease the reference count of the object and free it if this was the last reference.
- */
-void flib_map_destroy(flib_map *map);
-
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef MODEL_MAP_H_
+#define MODEL_MAP_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#define MAPGEN_REGULAR 0
+#define MAPGEN_MAZE 1
+#define MAPGEN_DRAWN 2
+#define MAPGEN_NAMED 3
+
+#define TEMPLATEFILTER_ALL 0
+#define TEMPLATEFILTER_SMALL 1
+#define TEMPLATEFILTER_MEDIUM 2
+#define TEMPLATEFILTER_LARGE 3
+#define TEMPLATEFILTER_CAVERN 4
+#define TEMPLATEFILTER_WACKY 5
+
+#define MAZE_SIZE_SMALL_TUNNELS 0
+#define MAZE_SIZE_MEDIUM_TUNNELS 1
+#define MAZE_SIZE_LARGE_TUNNELS 2
+#define MAZE_SIZE_SMALL_ISLANDS 3
+#define MAZE_SIZE_MEDIUM_ISLANDS 4
+#define MAZE_SIZE_LARGE_ISLANDS 5
+
+/**
+ * Data structure for defining a map. This contains the whole recipe to
+ * exactly recreate a particular map.
+ *
+ * The required fields depend on the map generator, see the comments
+ * at the struct for details.
+ */
+typedef struct {
+	int mapgen;				//!< Always one of the MAPGEN_ constants
+	char *name;				//!< The name of the map for MAPGEN_NAMED (e.g. "Cogs"), otherwise one of "+rnd+", "+maze+" or "+drawn+".
+	char *seed;				//!< Used for all maps. This is a random seed for all (non-AI) entropy in the round. Typically a random UUID, but can be any string.
+	char *theme;			//!< Used for all maps. This is the name of a directory in Data/Themes (e.g. "Beach")
+	uint8_t *drawData;		//!< Used for MAPGEN_DRAWN
+	size_t drawDataSize;	//!< Used for MAPGEN_DRAWN
+	int templateFilter;		//!< Used for MAPGEN_REGULAR. One of the TEMPLATEFILTER_xxx constants.
+	int mazeSize;			//!< Used for MAPGEN_MAZE. One of the MAZE_SIZE_xxx constants.
+} flib_map;
+
+/**
+ * Create a generated map. theme should be the name of a
+ * directory in "Themes" and templateFilter should be one of the
+ * TEMPLATEFILTER_* constants, but this is not checked before
+ * passing it to the engine.
+ *
+ * Use flib_map_destroy to free the returned object.
+ * No NULL parameters allowed, returns NULL on failure.
+ */
+flib_map *flib_map_create_regular(const char *seed, const char *theme, int templateFilter);
+
+/**
+ * Create a generated maze-type map. theme should be the name of a
+ * directory in "Themes" and mazeSize should be one of the
+ * MAZE_SIZE_* constants, but this is not checked before
+ * passing it to the engine.
+ *
+ * Use flib_map_destroy to free the returned object.
+ * No NULL parameters allowed, returns NULL on failure.
+ */
+flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize);
+
+/**
+ * Create a map from the Maps-Directory. name should be the name of a
+ * directory in "Maps", but this is not checked before
+ * passing it to the engine. If this is a mission, the corresponding
+ * script is used automatically.
+ *
+ * Use flib_map_destroy to free the returned object.
+ * No NULL parameters allowed, returns NULL on failure.
+ */
+flib_map *flib_map_create_named(const char *seed, const char *name);
+
+/**
+ * Create a hand-drawn map. Use flib_map_destroy to free the returned object.
+ * No NULL parameters allowed, returns NULL on failure.
+ */
+flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize);
+
+/**
+ * Create a deep copy of the map. Returns NULL on failure or if NULL was passed.
+ */
+flib_map *flib_map_copy(const flib_map *map);
+
+/**
+ * Decrease the reference count of the object and free it if this was the last reference.
+ */
+void flib_map_destroy(flib_map *map);
+
+
+#endif
--- a/project_files/frontlib/model/mapcfg.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/model/mapcfg.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,38 +1,38 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/*!
- * Data structure and functions for accessing the map.cfg of named maps.
- */
-
-#ifndef MAPCFG_H_
-#define MAPCFG_H_
-
-typedef struct {
-    char theme[256];
-    int hogLimit;
-} flib_mapcfg;
-
-/**
- * Read the map configuration for the map with this name.
- * The dataDirPath must end in a path separator.
- */
-int flib_mapcfg_read(const char *dataDirPath, const char *mapname, flib_mapcfg *out);
-
-#endif /* MAPCFG_H_ */
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/*!
+ * Data structure and functions for accessing the map.cfg of named maps.
+ */
+
+#ifndef MAPCFG_H_
+#define MAPCFG_H_
+
+typedef struct {
+	char theme[256];
+	int hogLimit;
+} flib_mapcfg;
+
+/**
+ * Read the map configuration for the map with this name.
+ * The dataDirPath must end in a path separator.
+ */
+int flib_mapcfg_read(const char *dataDirPath, const char *mapname, flib_mapcfg *out);
+
+#endif /* MAPCFG_H_ */
--- a/project_files/frontlib/model/room.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/model/room.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,42 +1,42 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/**
- * Models the room information for the lobby roomlist.
- */
-
-#ifndef ROOM_H_
-#define ROOM_H_
-
-#include <stdbool.h>
-
-typedef struct {
-    bool inProgress;    //!< true if the game is running
-    char *name;
-    int playerCount;
-    int teamCount;
-    char *owner;
-    char *map;          //!< This is either a map name, or one of +rnd+, +maze+ or +drawn+.
-    char *scheme;
-    char *weapons;
-} flib_room;
-
-void flib_room_destroy();
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * Models the room information for the lobby roomlist.
+ */
+
+#ifndef ROOM_H_
+#define ROOM_H_
+
+#include <stdbool.h>
+
+typedef struct {
+    bool inProgress;	//!< true if the game is running
+    char *name;
+    int playerCount;
+    int teamCount;
+    char *owner;
+    char *map;			//!< This is either a map name, or one of +rnd+, +maze+ or +drawn+.
+    char *scheme;
+    char *weapons;
+} flib_room;
+
+void flib_room_destroy();
+
+#endif
--- a/project_files/frontlib/model/team.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/model/team.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,130 +1,130 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/**
- * This file defines a data structure for a hedgewars team.
- *
- * Teams are used in several different contexts in Hedgewars, and some of these require
- * extra information about teams. For example, the weaponset is important
- * to the engine, but not for ini reading/writing, and with the team statistics it is the
- * other way around. To keep things simple, the data structure can hold all information
- * used in any context. On the downside, that means we can't use static typing to ensure
- * that team information is "complete" for a particular purpose.
- */
-#ifndef TEAM_H_
-#define TEAM_H_
-
-
-#include "weapon.h"
-#include "../hwconsts.h"
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#define TEAM_DEFAULT_HEALTH 100
-
-/**
- * Struct representing a single keybinding.
- */
-typedef struct {
-    char *action;
-    char *binding;
-} flib_binding;
-
-typedef struct {
-    char *name;
-    char *hat;          //!< e.g. hair_yellow; References a .png file in Data/Graphics/Hats
-
-    //! Statistics. They are irrelevant for the engine or server,
-    //! but provided for ini reading/writing by the frontend.
-    int rounds;
-    int kills;
-    int deaths;
-    int suicides;
-
-    int difficulty;     //!< 0 = human, 1 = most difficult bot ... 5 = least difficult bot (somewhat counterintuitive)
-
-    //! Transient setting used in game setup
-    int initialHealth;
-    flib_weaponset *weaponset;
-} flib_hog;
-
-typedef struct {
-    flib_hog hogs[HEDGEHOGS_PER_TEAM];
-    char *name;
-    char *grave;        //!< e.g. "Bone"; References a .png file in Data/Graphics/Graves
-    char *fort;         //!< e.g. "Castle"; References a series of files in Data/Forts
-    char *voicepack;    //!< e.g. "Classic"; References a directory in Data/Sounds/voices
-    char *flag;         //!< e.g. "hedgewars"; References a .png file in Data/Graphics/Flags
-
-    flib_binding *bindings;
-    int bindingCount;
-
-    //! Statistics. They are irrelevant for the engine or server,
-    //! but provided for ini reading/writing by the frontend.
-    int rounds;
-    int wins;
-    int campaignProgress;
-
-    //! Transient settings used in game setup
-    int colorIndex;     //!< Index into a color table
-    int hogsInGame;     //!< The number of hogs that will actually play
-    bool remoteDriven;  //!< true for non-local teams in a network game
-    char *ownerName;    //!< Username of the owner of a team in a network game
-} flib_team;
-
-/**
- * Free all memory associated with the team
- */
-void flib_team_destroy(flib_team *team);
-
-/**
- * Loads a team, returns NULL on error. Destroy this team using flib_team_destroy.
- * This will not fill in the fields marked as "transient" in the structs above.
- */
-flib_team *flib_team_from_ini(const char *filename);
-
-/**
- * Write the team to an ini file. Attempts to retain extra ini settings
- * that were already present. Note that not all fields of a team struct
- * are stored in the ini, some are only used intermittently to store
- * information about a team in the context of a game.
- *
- * The flib_team can handle "difficulty" on a per-hog basis, but it
- * is only written per-team in the team file. The difficulty of the
- * first hog is used for the entire team when writing.
- */
-int flib_team_to_ini(const char *filename, const flib_team *team);
-
-/**
- * Set the same weaponset for every hog in the team
- */
-int flib_team_set_weaponset(flib_team *team, const flib_weaponset *set);
-
-/**
- * Set the same initial health for every hog.
- */
-void flib_team_set_health(flib_team *team, int health);
-
-/**
- * Create a deep copy of a team. Returns NULL on failure.
- */
-flib_team *flib_team_copy(const flib_team *team);
-
-#endif /* TEAM_H_ */
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * This file defines a data structure for a hedgewars team.
+ *
+ * Teams are used in several different contexts in Hedgewars, and some of these require
+ * extra information about teams. For example, the weaponset is important
+ * to the engine, but not for ini reading/writing, and with the team statistics it is the
+ * other way around. To keep things simple, the data structure can hold all information
+ * used in any context. On the downside, that means we can't use static typing to ensure
+ * that team information is "complete" for a particular purpose.
+ */
+#ifndef TEAM_H_
+#define TEAM_H_
+
+
+#include "weapon.h"
+#include "../hwconsts.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#define TEAM_DEFAULT_HEALTH 100
+
+/**
+ * Struct representing a single keybinding.
+ */
+typedef struct {
+	char *action;
+	char *binding;
+} flib_binding;
+
+typedef struct {
+	char *name;
+	char *hat;			//!< e.g. hair_yellow; References a .png file in Data/Graphics/Hats
+
+	//! Statistics. They are irrelevant for the engine or server,
+	//! but provided for ini reading/writing by the frontend.
+	int rounds;
+	int kills;
+	int deaths;
+	int suicides;
+
+	int difficulty;		//!< 0 = human, 1 = most difficult bot ... 5 = least difficult bot (somewhat counterintuitive)
+
+	//! Transient setting used in game setup
+	int initialHealth;
+	flib_weaponset *weaponset;
+} flib_hog;
+
+typedef struct {
+	flib_hog hogs[HEDGEHOGS_PER_TEAM];
+	char *name;
+	char *grave;		//!< e.g. "Bone"; References a .png file in Data/Graphics/Graves
+	char *fort;			//!< e.g. "Castle"; References a series of files in Data/Forts
+	char *voicepack;	//!< e.g. "Classic"; References a directory in Data/Sounds/voices
+	char *flag;			//!< e.g. "hedgewars"; References a .png file in Data/Graphics/Flags
+
+	flib_binding *bindings;
+	int bindingCount;
+
+	//! Statistics. They are irrelevant for the engine or server,
+	//! but provided for ini reading/writing by the frontend.
+	int rounds;
+	int wins;
+	int campaignProgress;
+
+	//! Transient settings used in game setup
+	int colorIndex;		//!< Index into a color table
+	int hogsInGame;		//!< The number of hogs that will actually play
+	bool remoteDriven;	//!< true for non-local teams in a network game
+	char *ownerName;	//!< Username of the owner of a team in a network game
+} flib_team;
+
+/**
+ * Free all memory associated with the team
+ */
+void flib_team_destroy(flib_team *team);
+
+/**
+ * Loads a team, returns NULL on error. Destroy this team using flib_team_destroy.
+ * This will not fill in the fields marked as "transient" in the structs above.
+ */
+flib_team *flib_team_from_ini(const char *filename);
+
+/**
+ * Write the team to an ini file. Attempts to retain extra ini settings
+ * that were already present. Note that not all fields of a team struct
+ * are stored in the ini, some are only used intermittently to store
+ * information about a team in the context of a game.
+ *
+ * The flib_team can handle "difficulty" on a per-hog basis, but it
+ * is only written per-team in the team file. The difficulty of the
+ * first hog is used for the entire team when writing.
+ */
+int flib_team_to_ini(const char *filename, const flib_team *team);
+
+/**
+ * Set the same weaponset for every hog in the team
+ */
+int flib_team_set_weaponset(flib_team *team, const flib_weaponset *set);
+
+/**
+ * Set the same initial health for every hog.
+ */
+void flib_team_set_health(flib_team *team, int health);
+
+/**
+ * Create a deep copy of a team. Returns NULL on failure.
+ */
+flib_team *flib_team_copy(const flib_team *team);
+
+#endif /* TEAM_H_ */
--- a/project_files/frontlib/net/netconn.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/net/netconn.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,7 +1,7 @@
 /*
  * Hedgewars, a free turn based strategy game
  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
  * Copyright (c) 2012 Simeon Maxein <smaxein@googlemail.com>
  *
  * This program is free software; you can redistribute it and/or modify
--- a/project_files/frontlib/net/netconn.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/net/netconn.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,654 +1,654 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/**
- * This file contains functions for communicating with a Hedgewars server to chat, prepare and play
- * rounds of Hedgewars.
- *
- * To use this, first create a netconn object by calling flib_netconn_create. This will start the
- * connection to the game server (which might fail right away, the function returns null then). You
- * should also register your callback functions right at the start to ensure you don't miss any
- * callbacks.
- *
- * In order to allow the netconn to run, you should regularly call flib_netconn_tick(), which
- * performs network I/O and calls your callbacks on interesting events.
- *
- * When the connection is closed, you will receive the onDisconnect callback. This is the signal to
- * destroy the netconn and stop calling tick().
- *
- * The connection process lasts from the time you create the netconn until you receive the
- * onConnected callback (or onDisconnected in case something goes wrong). During that time, you
- * might receive the onNickTaken and onPasswordRequest callbacks; see their description for more
- * information on how to handle them. You could also receive other callbacks during connecting (e.g.
- * about the room list), but it should be safe to ignore them.
- *
- * Once you are connected, you are in the lobby, and you can enter rooms and leave them again. The
- * room and lobby states have different protocols, so many commands only work in either one or the
- * other. If you are in a room you might also be in a game, but most of the functions behave the
- * same ingame as in a room.
- *
- * The state changes from lobby to room when the server tells you that you just entered one, which
- * will also trigger the onEnterRoom callback. This usually happens in reply to either a joinRoom,
- * createRoom or playerFollow command.
- *
- * The state changes back to lobby when the room is dissolved, when you are kicked from the room, or
- * when you actively leave the room using flib_netconn_send_leaveRoom. The first two events will
- * trigger the onLeaveRoom callback.
- */
-
-#ifndef NETCONN_H_
-#define NETCONN_H_
-
-#include "../model/gamesetup.h"
-#include "../model/scheme.h"
-#include "../model/room.h"
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#define NETCONN_STATE_CONNECTING 0
-#define NETCONN_STATE_LOBBY 1
-#define NETCONN_STATE_ROOM 2
-#define NETCONN_STATE_DISCONNECTED 10
-
-#define NETCONN_DISCONNECT_NORMAL 0             //!< The connection was closed normally
-#define NETCONN_DISCONNECT_SERVER_TOO_OLD 1     //!< The server has a lower protocol version than we do
-#define NETCONN_DISCONNECT_AUTH_FAILED 2        //!< You sent a password with flib_netconn_send_password that was not accepted
-#define NETCONN_DISCONNECT_CONNLOST 3           //!< The network connection was lost
-#define NETCONN_DISCONNECT_INTERNAL_ERROR 100   //!< Something went wrong in frontlib itself
-
-#define NETCONN_ROOMLEAVE_ABANDONED 0           //!< The room was closed because the chief left
-#define NETCONN_ROOMLEAVE_KICKED 1              //!< You have been kicked from the room
-
-#define NETCONN_MSG_TYPE_PLAYERINFO 0           //!< A response to flib_netconn_send_playerInfo
-#define NETCONN_MSG_TYPE_SERVERMESSAGE 1        //!< The welcome message when connecting to the lobby
-#define NETCONN_MSG_TYPE_WARNING 2              //!< A general warning message
-#define NETCONN_MSG_TYPE_ERROR 3                //!< A general error message
-
-#define NETCONN_MAPCHANGE_FULL 0
-#define NETCONN_MAPCHANGE_MAP 1
-#define NETCONN_MAPCHANGE_MAPGEN 2
-#define NETCONN_MAPCHANGE_DRAWNMAP 3
-#define NETCONN_MAPCHANGE_MAZE_SIZE 4
-#define NETCONN_MAPCHANGE_TEMPLATE 5
-#define NETCONN_MAPCHANGE_THEME 6
-#define NETCONN_MAPCHANGE_SEED 7
-
-typedef struct _flib_netconn flib_netconn;
-
-/**
- * Create a new netplay connection with these parameters.
- * The path to the data directory must end with a path delimiter (e.g. C:\Games\Hedgewars\Data\)
- */
-flib_netconn *flib_netconn_create(const char *playerName, const char *dataDirPath, const char *host, int port);
-void flib_netconn_destroy(flib_netconn *conn);
-
-/**
- * Perform I/O operations and call callbacks if something interesting happens.
- * Should be called regularly.
- */
-void flib_netconn_tick(flib_netconn *conn);
-
-/**
- * Are you currently the owner of this room? The return value only makes sense in
- * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states.
- */
-bool flib_netconn_is_chief(flib_netconn *conn);
-
-/**
- * Returns the playername. This is *probably* the one provided on creation, but if that name was
- * already taken, a different one could have been set by the onNickTaken callback or its default
- * implementation.
- */
-const char *flib_netconn_get_playername(flib_netconn *conn);
-
-/**
- * Generate a game setup from the current room state.
- * Returns NULL if the room state does not contain enough information for a complete game setup,
- * or if an error occurs.
- *
- * The new gamesetup must be destroyed with flib_gamesetup_destroy().
- */
-flib_gamesetup *flib_netconn_create_gamesetup(flib_netconn *conn);
-
-
-
-
-// Send functions needed when connecting and disconnecting
-
-    /**
-     * Request a different nickname.
-     * This function only makes sense in reaction to an onNickTaken callback, because the netconn
-     * automatically requests the nickname you provide on creation, and once the server accepts the
-     * nickname it can no longer be changed.
-     */
-    int flib_netconn_send_nick(flib_netconn *conn, const char *nick);
-
-    /**
-     * Send the password in reply to a password request.
-     * If the server does not accept the password, you will be disconnected
-     * (NETCONN_DISCONNECT_AUTH_FAILED)
-     */
-    int flib_netconn_send_password(flib_netconn *conn, const char *passwd);
-
-    /**
-     * Tell the server that you want to leave. If successful, the server will disconnect you.
-     */
-    int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg);
-
-
-// Send functions that make sense both in the lobby and in rooms
-
-    /**
-     * Send a chat message. This message is either sent to the lobby or the room, depending on
-     * whether you are in a room at the moment. The message is not echoed back to you.
-     */
-    int flib_netconn_send_chat(flib_netconn *conn, const char *chat);
-
-    /**
-     * Kick a player. This has different meanings in the lobby and in a room;
-     * In the lobby, it will kick the player from the server, and you need to be a server admin to
-     * do it. In a room, it will kick the player from the room, and you need to be room chief.
-     */
-    int flib_netconn_send_kick(flib_netconn *conn, const char *playerName);
-
-    /**
-     * Request information about a player (e.g. current room, version, partial IP). If the action
-     * succeeds, you will receive an onMessage callback with NETCONN_MSG_TYPE_PLAYERINFO containing
-     * the requested information.
-     */
-    int flib_netconn_send_playerInfo(flib_netconn *conn, const char *playerName);
-
-
-// Send functions that only make sense in the lobby
-
-    /**
-     * Request an update of the room list. Only makes sense when in lobby state.
-     * If the action succeeds, you will receive an onRoomlist callback containing the current room
-     * data.
-     */
-    int flib_netconn_send_request_roomlist(flib_netconn *conn);
-
-    /**
-     * Join a room as guest (not chief). Only makes sense when in lobby state. If the action
-     * succeeds, you will receive an onEnterRoom callback with chief=false followed by other
-     * callbacks with current room information.
-     */
-    int flib_netconn_send_joinRoom(flib_netconn *conn, const char *room);
-
-    /**
-     * Follow a player. Only valid in the lobby. If the player is in a room (or in a game), this
-     * command is analogous to calling flib_netconn_send_joinRoom with that room.
-     */
-    int flib_netconn_send_playerFollow(flib_netconn *conn, const char *playerName);
-
-    /**
-     * Create and join a new room. Only makes sense when in lobby state. If the action succeeds,
-     * you will receive an onEnterRoom callback with chief=true.
-     */
-    int flib_netconn_send_createRoom(flib_netconn *conn, const char *room);
-
-    /**
-     * Ban a player. The scope of this ban depends on whether you are in a room or in the lobby.
-     * In a room, you need to be the room chief, and the ban will apply to the room only. In the
-     * lobby, you need to be server admin to ban someone, and the ban applies to the entire server.
-     */
-    int flib_netconn_send_ban(flib_netconn *conn, const char *playerName);
-
-    /**
-     * Does something administrator-y. At any rate you need to be an administrator and in the lobby
-     * to use this command.
-     */
-    int flib_netconn_send_clearAccountsCache(flib_netconn *conn);
-
-    /**
-     * Sets a server variable to the indicated value. Only makes sense if you are server admin and
-     * in the lobby. Known variables are MOTD_NEW, MOTD_OLD and LATEST_PROTO. MOTD_OLD is shown to
-     * players with older protocol versions, to inform them that they might want to update.
-     */
-    int flib_netconn_send_setServerVar(flib_netconn *conn, const char *name, const char *value);
-
-    /**
-     * Queries all server variables. Only makes sense if you are server admin and in the lobby.
-     * If the action succeeds, you will receive several onServerVar callbacks with the
-     * current values of all server variables.
-     */
-    int flib_netconn_send_getServerVars(flib_netconn *conn);
-
-
-// Send functions that only make sense in a room
-
-    /**
-     * Leave the room for the lobby. Only makes sense in room state. msg can be NULL if you don't
-     * want to send a message. The server always accepts a part command, so once you send it off,
-     * you can just assume that you are back in the lobby.
-     */
-    int flib_netconn_send_leaveRoom(flib_netconn *conn, const char *msg);
-
-    /**
-     * Change your "ready" status in the room. Only makes sense when in room state. If the action
-     * succeeds, you will receive an onClientFlags callback containing the change.
-     */
-    int flib_netconn_send_toggleReady(flib_netconn *conn);
-
-    /**
-     * Add a team to the current room. Apart from the "fixed" team information, this also includes
-     * the color, but not the number of hogs. Only makes sense when in room state. If the action
-     * succeeds, you will receive an onTeamAccepted callback with the name of the team.
-     *
-     * Notes: Technically, sending a color here is the only way for a non-chief to set the color of
-     * her own team. The server remembers this color and even generates a separate teamColor message
-     * to inform everyone of it. However, at the moment the frontends generally override this color
-     * with one they choose themselves in order to deal with unfortunate behavior of the QtFrontend,
-     * which always sends color index 0 when adding a team but thinks that the team has a random
-     * color. The chief always sends a new color in order to bring the QtFrontend back into sync.
-     */
-    int flib_netconn_send_addTeam(flib_netconn *conn, const flib_team *team);
-
-    /**
-     * Remove the team with the name teamname. Only makes sense when in room state.
-     * The server does not send a reply on success.
-     */
-    int flib_netconn_send_removeTeam(flib_netconn *conn, const char *teamname);
-
-
-// Send functions that only make sense in a room and if you are room chief
-
-    /**
-     * Rename the current room. Only makes sense in room state and if you are chief. If the action
-     * succeeds, you (and everyone else on the server) will receive an onRoomUpdate message
-     * containing the change.
-     */
-    int flib_netconn_send_renameRoom(flib_netconn *conn, const char *roomName);
-
-    /**
-     * Set the number of hogs for a team. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_teamHogCount(flib_netconn *conn, const char *teamname, int hogcount);
-
-    /**
-     * Set the teamcolor of a team. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, int colorIndex);
-
-    /**
-     * Set the weaponset for the room. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_weaponset(flib_netconn *conn, const flib_weaponset *weaponset);
-
-    /**
-     * Set the map for the room. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_map(flib_netconn *conn, const flib_map *map);
-
-    /**
-     * Set the mapname. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapName(flib_netconn *conn, const char *mapName);
-
-    /**
-     * Set the map generator (regular, maze, drawn, named). Only makes sense in room state and if
-     * you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapGen(flib_netconn *conn, int mapGen);
-
-    /**
-     * Set the map template for regular maps. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapTemplate(flib_netconn *conn, int templateFilter);
-
-    /**
-     * Set the maze template (maze size) for mazes. Only makes sense in room state and if you are
-     * chief. The server does not send a reply.
-     */
-    int flib_netconn_send_mapMazeSize(flib_netconn *conn, int mazeSize);
-
-    /**
-     * Set the seed for the map. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapSeed(flib_netconn *conn, const char *seed);
-
-    /**
-     * Set the theme for the map. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapTheme(flib_netconn *conn, const char *theme);
-
-    /**
-     * Set the draw data for the drawn map. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_mapDrawdata(flib_netconn *conn, const uint8_t *drawData, size_t size);
-
-    /**
-     * Set the script (game style). Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_script(flib_netconn *conn, const char *scriptName);
-
-    /**
-     * Set the scheme. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_scheme(flib_netconn *conn, const flib_scheme *scheme);
-
-    /**
-     * Signal that you want to start the game. Only makes sense in room state and if you are chief.
-     * The server will check whether all players are ready and whether it believes the setup makes
-     * sense (e.g. more than one clan). If the server is satisfied, you will receive an onRunGame
-     * callback (all other clients in the room are notified the same way). Otherwise the server
-     * might answer with a warning, or might not answer at all.
-     */
-    int flib_netconn_send_startGame(flib_netconn *conn);
-
-    /**
-     * Allow/forbid players to join the room. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_toggleRestrictJoins(flib_netconn *conn);
-
-    /**
-     * Allow/forbid adding teams to the room. Only makes sense in room state and if you are chief.
-     * The server does not send a reply.
-     */
-    int flib_netconn_send_toggleRestrictTeams(flib_netconn *conn);
-
-
-// Send functions that are only needed for running a game
-
-    /**
-     * Send a teamchat message, forwarded from the engine. Only makes sense ingame.
-     * The server does not send a reply. In contrast to a Chat message, the server
-     * automatically converts this into an engine message and passes it on to the other
-     * clients.
-     */
-    int flib_netconn_send_teamchat(flib_netconn *conn, const char *msg);
-
-    /**
-     * Send an engine message. Only makes sense when ingame. In a networked game, you have to pass
-     * all the engine messages from the engine here, and they will be spread to all other clients
-     * in the game to keep the game in sync.
-     */
-    int flib_netconn_send_engineMessage(flib_netconn *conn, const uint8_t *message, size_t size);
-
-    /**
-     * Inform the server that the round has ended. Call this when the engine has disconnected,
-     * passing 1 if the round ended normally, 0 otherwise.
-     */
-    int flib_netconn_send_roundfinished(flib_netconn *conn, bool withoutError);
-
-
-
-
-
-// Callbacks that are important for connecting/disconnecting
-
-    /**
-     * onNickTaken is called when connecting to the server, if it turns out that there is already a
-     * player with the same nick.
-     * In order to proceed, a new nickname needs to be sent to the server using
-     * flib_netconn_send_nick() (or of course you can bail out and send a QUIT).
-     * If you don't set a callback, the netconn will automatically react by generating a new name.
-     */
-    void flib_netconn_onNickTaken(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
-
-    /**
-     * When connecting with a registered nickname, the server will ask for a password before
-     * admitting you in. This callback is called when that happens. As a reaction, you can send the
-     * password using flib_netconn_send_password. If you don't register a callback, the default
-     * behavior is to just quit in a way that will cause a disconnect with
-     * NETCONN_DISCONNECT_AUTH_FAILED.
-     *
-     * You can't just choose a new nickname when you receive this callback, because at that point
-     * the server has already accepted your nick.
-     */
-    void flib_netconn_onPasswordRequest(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
-
-    /**
-     * This is called when the server has accepted our nickname (and possibly password) and we have
-     * entered the lobby.
-     */
-    void flib_netconn_onConnected(flib_netconn *conn, void (*callback)(void *context), void* context);
-
-    /**
-     * This is always the last callback (unless the netconn is destroyed early), and the netconn
-     * should be destroyed when it is received. The reason for the disconnect is passed as one of
-     * the NETCONN_DISCONNECT_ constants. Sometimes a message is included as well, but that
-     * parameter might also be NULL.
-     */
-    void flib_netconn_onDisconnected(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void* context);
-
-
-// Callbacks that make sense in most situations
-
-    /**
-     * Callback for several informational messages that should be displayed to the user
-     * (e.g. in the chat window), but do not require a reaction. If a game is running, you might
-     * want to redirect some of these messages to the engine as well so the user will see them.
-     */
-    void flib_netconn_onMessage(flib_netconn *conn, void (*callback)(void *context, int msgtype, const char *msg), void* context);
-
-    /**
-     * We received a chat message. Where this message belongs depends on the current state
-     * (lobby/room). If a game is running the message should be passed to the engine.
-     */
-    void flib_netconn_onChat(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *msg), void* context);
-
-    /**
-     * Callbacks for incremental room list updates. They will fire whenever these events occur,
-     * even before you first query the actual roomlist - so be sure not to blindly reference your
-     * room list in these callbacks. The server currently only sends updates when a room changes
-     * its name, so in order to update other room information you need to query the roomlist again
-     * (see send_request_roomlist / onRoomlist).
-     */
-    void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_room *room), void* context);
-    void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context);
-    void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_room *room), void* context);
-
-    /**
-     * Callbacks for players joining or leaving the lobby. In contrast to the roomlist updates, you
-     * will get a JOIN callback for every player already on the server when you join (and there is
-     * no direct way to query the current playerlist)
-     *
-     * NOTE: partMessage may be NULL.
-     */
-    void flib_netconn_onLobbyJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
-    void flib_netconn_onLobbyLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context);
-
-    /**
-     * This is called when the server informs us that one or more flags associated with a
-     * player/client have changed.
-     *
-     * nick is the name of the player, flags is a string containing one character for each modified
-     * flag (see below), and newFlagState signals whether the flags should be set to true or false.
-     *
-     * Some of these flags are important for protocol purposes (especially if they are set for you)
-     * while others are just informational. Also, some flags are only relevant for players who are
-     * in the same room as you, and the server will not inform you if they change for others.
-     *
-     * These are the currently known/used flags:
-     * a: Server admin. Always updated.
-     * h: Room chief. Updated when in the same room.
-     * r: Ready to play. Updated when in the same room.
-     * u: Registered user. Always updated.
-     *
-     * The server tells us the 'a' and 'u' flags for all players when we first join the lobby, and
-     * also tells us the 'r' and 'h' flags when we join or create a room. It assumes that all flags
-     * are initially false, so it will typically only tell you to set certain flags to true when
-     * transmitting the initial states. Reset the 'h' and 'r' flags to false when leaving a room,
-     * or when entering room state, to arrive at the right state for each player.
-     *
-     * The room chief state of yourself is particularly important because it determines whether you
-     * can modify settings of the current room. Generally, when you create a room you start out
-     * being room chief, and when you join an existing room you are not. However, if the original
-     * chief leaves a room, the server can choose a new chief, and if that happens the chief flag
-     * will be transferred to someone else.
-     */
-    void flib_netconn_onClientFlags(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *flags, bool newFlagState), void *context);
-
-// Callbacks that happen only in response to specific requests
-
-    /**
-     * Response to flib_netconn_send_request_roomlist().
-     * The rooms array contains the current state of all rooms on the server.
-     */
-    void flib_netconn_onRoomlist(flib_netconn *conn, void (*callback)(void *context, const flib_room **rooms, int roomCount), void* context);
-
-    /**
-     * Response to flib_netconn_send_joinRoom, flib_netconn_send_playerFollow or
-     * flib_netconn_send_createRoom.
-     *
-     * You just left the lobby and entered a room.
-     * If chief is true, you can and should send a full configuration for the room now. This
-     * consists of ammo, scheme, script and map, where map apparently has to come last.
-     */
-    void flib_netconn_onEnterRoom(flib_netconn *conn, void (*callback)(void *context, bool chief), void *context);
-
-    /**
-     * Response to flib_netconn_send_addTeam.
-     * The server might reject your team for several reasons, e.g. because it has the same name as
-     * an existing team, or because the room chief restricted adding new teams. If the team is
-     * accepted by the server, this callback is fired.
-     *
-     * If you are the room chief, you are expected to provide the hog count for your own team now
-     * using flib_netconn_send_teamHogCount. The color of the team is already set to the one you
-     * provided in addTeam.
-     */
-    void flib_netconn_onTeamAccepted(flib_netconn *conn, void (*callback)(void *context, const char *team), void *context);
-
-    /**
-     * When you query the server vars with flib_netconn_send_getServerVars (only works as admin),
-     * the server replies with a list of them. This callback is called for each entry in that list.
-     */
-    void flib_netconn_onServerVar(flib_netconn *conn, void (*callback)(void *context, const char *name, const char *value), void *context);
-
-
-// Callbacks that are only relevant in a room
-
-    /**
-     * You just left a room and entered the lobby again.
-     * reason is one of the NETCONN_ROOMLEAVE_ constants (usually a kick).
-     * This will not be called when you actively leave a room using PART.
-     * Don't confuse with onRoomLeave, which indicates that *someone else* left the room.
-     */
-    void flib_netconn_onLeaveRoom(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void *context);
-
-    /**
-     * Someone joined or left the room you are currently in.
-     * Analogous to onLobbyJoin/leave, you will receive the join callback for all players that are
-     * already in the room when you join, including for yourself (this is actually how it is
-     * determined that you joined a room).
-     *
-     * However, you will *not* receive onRoomLeave messages for everyone when you leave the room.
-     */
-    void flib_netconn_onRoomJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
-    void flib_netconn_onRoomLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context);
-
-    /**
-     * A new team was added to the room. The person who adds a team does NOT receive this callback
-     * (he gets onTeamAccepted instead).
-     *
-     * The team does not contain bindings, stats, weaponset, color or the number of hogs (but it is
-     * assumed to be the default of 4).
-     *
-     * If you receive this message and you are the room chief, you may want to send a color and hog
-     * count for this team using flib_netconn_send_teamHogCount / teamColor for QtFrontend
-     * compatibility.
-     *
-     * The server currently sends another message with the color of the team to the same recipients
-     * as this teamAdd message, which will trigger an onTeamColorChanged callback. See the
-     * description of flib_netconn_send_addTeam for more information.
-     */
-    void flib_netconn_onTeamAdd(flib_netconn *conn, void (*callback)(void *context, const flib_team *team), void *context);
-
-    /**
-     * A team was removed from the room. The person who removed the team will not receive this
-     * callback.
-     */
-    void flib_netconn_onTeamDelete(flib_netconn *conn, void (*callback)(void *context, const char *teamname), void *context);
-
-    /**
-     * The number of hogs in a team has been changed by the room chief. If you are the chief and
-     * change the number of hogs yourself, you will not receive this callback.
-     */
-    void flib_netconn_onHogCountChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int hogs), void *context);
-
-    /**
-     * The color of a team has been set or changed. The client who set or changed the color will
-     * not receive this callback.
-     *
-     * Normally, only the chief can change the color of a team. However, this message is also
-     * generated when a team is added, so you can receive it even as chief.
-     */
-    void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int colorIndex), void *context);
-
-    /**
-     * The room chief has changed the game scheme (or you just joined a room).
-     * You will not receive this callback if you changed the scheme yourself.
-     */
-    void flib_netconn_onSchemeChanged(flib_netconn *conn, void (*callback)(void *context, const flib_scheme *scheme), void *context);
-
-    /**
-     * The room chief has changed the map (or you just joined a room). Only non-chiefs receive these
-     * messages.
-     *
-     * To reduce the number of callback functions, the netconn keeps track of the current map
-     * settings and always passes the entire current map config, but informs the callee about what
-     * has changed (see the NETCONN_MAPCHANGE_ constants).
-     *
-     * Caution: Due to the way the protocol works, the map might not be complete at this point if it
-     * is a hand-drawn map, because the "full" map config does not include the drawn map data.
-     */
-    void flib_netconn_onMapChanged(flib_netconn *conn, void (*callback)(void *context, const flib_map *map, int changetype), void *context);
-
-    /**
-     * The room chief has changed the game style (or you just joined a room). If you are the chief
-     * and change the style yourself, you will not receive this callback.
-     */
-    void flib_netconn_onScriptChanged(flib_netconn *conn, void (*callback)(void *context, const char *script), void *context);
-
-    /**
-     * The room chief has changed the weaponset (or you just joined a room). If you are the chief
-     * and change the weaponset yourself, you will not receive this callback.
-     */
-    void flib_netconn_onWeaponsetChanged(flib_netconn *conn, void (*callback)(void *context, const flib_weaponset *weaponset), void *context);
-
-    /**
-     * The game is starting. Fire up the engine and join in!
-     * You can let the netconn generate the right game setup using flib_netconn_create_gamesetup
-     */
-    void flib_netconn_onRunGame(flib_netconn *conn, void (*callback)(void *context), void *context);
-
-    /**
-     * You are in a room, a game is in progress, and the server is sending you the new input for the
-     * engine to keep up to date with the current happenings. Pass it on to the engine using
-     * flib_gameconn_send_enginemsg.
-     */
-    void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const uint8_t *message, size_t size), void *context);
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * This file contains functions for communicating with a Hedgewars server to chat, prepare and play
+ * rounds of Hedgewars.
+ *
+ * To use this, first create a netconn object by calling flib_netconn_create. This will start the
+ * connection to the game server (which might fail right away, the function returns null then). You
+ * should also register your callback functions right at the start to ensure you don't miss any
+ * callbacks.
+ *
+ * In order to allow the netconn to run, you should regularly call flib_netconn_tick(), which
+ * performs network I/O and calls your callbacks on interesting events.
+ *
+ * When the connection is closed, you will receive the onDisconnect callback. This is the signal to
+ * destroy the netconn and stop calling tick().
+ *
+ * The connection process lasts from the time you create the netconn until you receive the
+ * onConnected callback (or onDisconnected in case something goes wrong). During that time, you
+ * might receive the onNickTaken and onPasswordRequest callbacks; see their description for more
+ * information on how to handle them. You could also receive other callbacks during connecting (e.g.
+ * about the room list), but it should be safe to ignore them.
+ *
+ * Once you are connected, you are in the lobby, and you can enter rooms and leave them again. The
+ * room and lobby states have different protocols, so many commands only work in either one or the
+ * other. If you are in a room you might also be in a game, but most of the functions behave the
+ * same ingame as in a room.
+ *
+ * The state changes from lobby to room when the server tells you that you just entered one, which
+ * will also trigger the onEnterRoom callback. This usually happens in reply to either a joinRoom,
+ * createRoom or playerFollow command.
+ *
+ * The state changes back to lobby when the room is dissolved, when you are kicked from the room, or
+ * when you actively leave the room using flib_netconn_send_leaveRoom. The first two events will
+ * trigger the onLeaveRoom callback.
+ */
+
+#ifndef NETCONN_H_
+#define NETCONN_H_
+
+#include "../model/gamesetup.h"
+#include "../model/scheme.h"
+#include "../model/room.h"
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#define NETCONN_STATE_CONNECTING 0
+#define NETCONN_STATE_LOBBY 1
+#define NETCONN_STATE_ROOM 2
+#define NETCONN_STATE_DISCONNECTED 10
+
+#define NETCONN_DISCONNECT_NORMAL 0				//!< The connection was closed normally
+#define NETCONN_DISCONNECT_SERVER_TOO_OLD 1		//!< The server has a lower protocol version than we do
+#define NETCONN_DISCONNECT_AUTH_FAILED 2		//!< You sent a password with flib_netconn_send_password that was not accepted
+#define NETCONN_DISCONNECT_CONNLOST 3			//!< The network connection was lost
+#define NETCONN_DISCONNECT_INTERNAL_ERROR 100	//!< Something went wrong in frontlib itself
+
+#define NETCONN_ROOMLEAVE_ABANDONED 0			//!< The room was closed because the chief left
+#define NETCONN_ROOMLEAVE_KICKED 1				//!< You have been kicked from the room
+
+#define NETCONN_MSG_TYPE_PLAYERINFO 0			//!< A response to flib_netconn_send_playerInfo
+#define NETCONN_MSG_TYPE_SERVERMESSAGE 1		//!< The welcome message when connecting to the lobby
+#define NETCONN_MSG_TYPE_WARNING 2				//!< A general warning message
+#define NETCONN_MSG_TYPE_ERROR 3				//!< A general error message
+
+#define NETCONN_MAPCHANGE_FULL 0
+#define NETCONN_MAPCHANGE_MAP 1
+#define NETCONN_MAPCHANGE_MAPGEN 2
+#define NETCONN_MAPCHANGE_DRAWNMAP 3
+#define NETCONN_MAPCHANGE_MAZE_SIZE 4
+#define NETCONN_MAPCHANGE_TEMPLATE 5
+#define NETCONN_MAPCHANGE_THEME 6
+#define NETCONN_MAPCHANGE_SEED 7
+
+typedef struct _flib_netconn flib_netconn;
+
+/**
+ * Create a new netplay connection with these parameters.
+ * The path to the data directory must end with a path delimiter (e.g. C:\Games\Hedgewars\Data\)
+ */
+flib_netconn *flib_netconn_create(const char *playerName, const char *dataDirPath, const char *host, int port);
+void flib_netconn_destroy(flib_netconn *conn);
+
+/**
+ * Perform I/O operations and call callbacks if something interesting happens.
+ * Should be called regularly.
+ */
+void flib_netconn_tick(flib_netconn *conn);
+
+/**
+ * Are you currently the owner of this room? The return value only makes sense in
+ * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states.
+ */
+bool flib_netconn_is_chief(flib_netconn *conn);
+
+/**
+ * Returns the playername. This is *probably* the one provided on creation, but if that name was
+ * already taken, a different one could have been set by the onNickTaken callback or its default
+ * implementation.
+ */
+const char *flib_netconn_get_playername(flib_netconn *conn);
+
+/**
+ * Generate a game setup from the current room state.
+ * Returns NULL if the room state does not contain enough information for a complete game setup,
+ * or if an error occurs.
+ *
+ * The new gamesetup must be destroyed with flib_gamesetup_destroy().
+ */
+flib_gamesetup *flib_netconn_create_gamesetup(flib_netconn *conn);
+
+
+
+
+// Send functions needed when connecting and disconnecting
+
+	/**
+	 * Request a different nickname.
+	 * This function only makes sense in reaction to an onNickTaken callback, because the netconn
+	 * automatically requests the nickname you provide on creation, and once the server accepts the
+	 * nickname it can no longer be changed.
+	 */
+	int flib_netconn_send_nick(flib_netconn *conn, const char *nick);
+
+	/**
+	 * Send the password in reply to a password request.
+	 * If the server does not accept the password, you will be disconnected
+	 * (NETCONN_DISCONNECT_AUTH_FAILED)
+	 */
+	int flib_netconn_send_password(flib_netconn *conn, const char *passwd);
+
+	/**
+	 * Tell the server that you want to leave. If successful, the server will disconnect you.
+	 */
+	int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg);
+
+
+// Send functions that make sense both in the lobby and in rooms
+
+	/**
+	 * Send a chat message. This message is either sent to the lobby or the room, depending on
+	 * whether you are in a room at the moment. The message is not echoed back to you.
+	 */
+	int flib_netconn_send_chat(flib_netconn *conn, const char *chat);
+
+	/**
+	 * Kick a player. This has different meanings in the lobby and in a room;
+	 * In the lobby, it will kick the player from the server, and you need to be a server admin to
+	 * do it. In a room, it will kick the player from the room, and you need to be room chief.
+	 */
+	int flib_netconn_send_kick(flib_netconn *conn, const char *playerName);
+
+	/**
+	 * Request information about a player (e.g. current room, version, partial IP). If the action
+	 * succeeds, you will receive an onMessage callback with NETCONN_MSG_TYPE_PLAYERINFO containing
+	 * the requested information.
+	 */
+	int flib_netconn_send_playerInfo(flib_netconn *conn, const char *playerName);
+
+
+// Send functions that only make sense in the lobby
+
+	/**
+	 * Request an update of the room list. Only makes sense when in lobby state.
+	 * If the action succeeds, you will receive an onRoomlist callback containing the current room
+	 * data.
+	 */
+	int flib_netconn_send_request_roomlist(flib_netconn *conn);
+
+	/**
+	 * Join a room as guest (not chief). Only makes sense when in lobby state. If the action
+	 * succeeds, you will receive an onEnterRoom callback with chief=false followed by other
+	 * callbacks with current room information.
+	 */
+	int flib_netconn_send_joinRoom(flib_netconn *conn, const char *room);
+
+	/**
+	 * Follow a player. Only valid in the lobby. If the player is in a room (or in a game), this
+	 * command is analogous to calling flib_netconn_send_joinRoom with that room.
+	 */
+	int flib_netconn_send_playerFollow(flib_netconn *conn, const char *playerName);
+
+	/**
+	 * Create and join a new room. Only makes sense when in lobby state. If the action succeeds,
+	 * you will receive an onEnterRoom callback with chief=true.
+	 */
+	int flib_netconn_send_createRoom(flib_netconn *conn, const char *room);
+
+	/**
+	 * Ban a player. The scope of this ban depends on whether you are in a room or in the lobby.
+	 * In a room, you need to be the room chief, and the ban will apply to the room only. In the
+	 * lobby, you need to be server admin to ban someone, and the ban applies to the entire server.
+	 */
+	int flib_netconn_send_ban(flib_netconn *conn, const char *playerName);
+
+	/**
+	 * Does something administrator-y. At any rate you need to be an administrator and in the lobby
+	 * to use this command.
+	 */
+	int flib_netconn_send_clearAccountsCache(flib_netconn *conn);
+
+	/**
+	 * Sets a server variable to the indicated value. Only makes sense if you are server admin and
+	 * in the lobby. Known variables are MOTD_NEW, MOTD_OLD and LATEST_PROTO. MOTD_OLD is shown to
+	 * players with older protocol versions, to inform them that they might want to update.
+	 */
+	int flib_netconn_send_setServerVar(flib_netconn *conn, const char *name, const char *value);
+
+	/**
+	 * Queries all server variables. Only makes sense if you are server admin and in the lobby.
+	 * If the action succeeds, you will receive several onServerVar callbacks with the
+	 * current values of all server variables.
+	 */
+	int flib_netconn_send_getServerVars(flib_netconn *conn);
+
+
+// Send functions that only make sense in a room
+
+	/**
+	 * Leave the room for the lobby. Only makes sense in room state. msg can be NULL if you don't
+	 * want to send a message. The server always accepts a part command, so once you send it off,
+	 * you can just assume that you are back in the lobby.
+	 */
+	int flib_netconn_send_leaveRoom(flib_netconn *conn, const char *msg);
+
+	/**
+	 * Change your "ready" status in the room. Only makes sense when in room state. If the action
+	 * succeeds, you will receive an onClientFlags callback containing the change.
+	 */
+	int flib_netconn_send_toggleReady(flib_netconn *conn);
+
+	/**
+	 * Add a team to the current room. Apart from the "fixed" team information, this also includes
+	 * the color, but not the number of hogs. Only makes sense when in room state. If the action
+	 * succeeds, you will receive an onTeamAccepted callback with the name of the team.
+	 *
+	 * Notes: Technically, sending a color here is the only way for a non-chief to set the color of
+	 * her own team. The server remembers this color and even generates a separate teamColor message
+	 * to inform everyone of it. However, at the moment the frontends generally override this color
+	 * with one they choose themselves in order to deal with unfortunate behavior of the QtFrontend,
+	 * which always sends color index 0 when adding a team but thinks that the team has a random
+	 * color. The chief always sends a new color in order to bring the QtFrontend back into sync.
+	 */
+	int flib_netconn_send_addTeam(flib_netconn *conn, const flib_team *team);
+
+	/**
+	 * Remove the team with the name teamname. Only makes sense when in room state.
+	 * The server does not send a reply on success.
+	 */
+	int flib_netconn_send_removeTeam(flib_netconn *conn, const char *teamname);
+
+
+// Send functions that only make sense in a room and if you are room chief
+
+	/**
+	 * Rename the current room. Only makes sense in room state and if you are chief. If the action
+	 * succeeds, you (and everyone else on the server) will receive an onRoomUpdate message
+	 * containing the change.
+	 */
+	int flib_netconn_send_renameRoom(flib_netconn *conn, const char *roomName);
+
+	/**
+	 * Set the number of hogs for a team. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_teamHogCount(flib_netconn *conn, const char *teamname, int hogcount);
+
+	/**
+	 * Set the teamcolor of a team. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, int colorIndex);
+
+	/**
+	 * Set the weaponset for the room. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_weaponset(flib_netconn *conn, const flib_weaponset *weaponset);
+
+	/**
+	 * Set the map for the room. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_map(flib_netconn *conn, const flib_map *map);
+
+	/**
+	 * Set the mapname. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapName(flib_netconn *conn, const char *mapName);
+
+	/**
+	 * Set the map generator (regular, maze, drawn, named). Only makes sense in room state and if
+	 * you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapGen(flib_netconn *conn, int mapGen);
+
+	/**
+	 * Set the map template for regular maps. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapTemplate(flib_netconn *conn, int templateFilter);
+
+	/**
+	 * Set the maze template (maze size) for mazes. Only makes sense in room state and if you are
+	 * chief. The server does not send a reply.
+	 */
+	int flib_netconn_send_mapMazeSize(flib_netconn *conn, int mazeSize);
+
+	/**
+	 * Set the seed for the map. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapSeed(flib_netconn *conn, const char *seed);
+
+	/**
+	 * Set the theme for the map. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapTheme(flib_netconn *conn, const char *theme);
+
+	/**
+	 * Set the draw data for the drawn map. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_mapDrawdata(flib_netconn *conn, const uint8_t *drawData, size_t size);
+
+	/**
+	 * Set the script (game style). Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_script(flib_netconn *conn, const char *scriptName);
+
+	/**
+	 * Set the scheme. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_scheme(flib_netconn *conn, const flib_scheme *scheme);
+
+	/**
+	 * Signal that you want to start the game. Only makes sense in room state and if you are chief.
+	 * The server will check whether all players are ready and whether it believes the setup makes
+	 * sense (e.g. more than one clan). If the server is satisfied, you will receive an onRunGame
+	 * callback (all other clients in the room are notified the same way). Otherwise the server
+	 * might answer with a warning, or might not answer at all.
+	 */
+	int flib_netconn_send_startGame(flib_netconn *conn);
+
+	/**
+	 * Allow/forbid players to join the room. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_toggleRestrictJoins(flib_netconn *conn);
+
+	/**
+	 * Allow/forbid adding teams to the room. Only makes sense in room state and if you are chief.
+	 * The server does not send a reply.
+	 */
+	int flib_netconn_send_toggleRestrictTeams(flib_netconn *conn);
+
+
+// Send functions that are only needed for running a game
+
+	/**
+	 * Send a teamchat message, forwarded from the engine. Only makes sense ingame.
+	 * The server does not send a reply. In contrast to a Chat message, the server
+	 * automatically converts this into an engine message and passes it on to the other
+	 * clients.
+	 */
+	int flib_netconn_send_teamchat(flib_netconn *conn, const char *msg);
+
+	/**
+	 * Send an engine message. Only makes sense when ingame. In a networked game, you have to pass
+	 * all the engine messages from the engine here, and they will be spread to all other clients
+	 * in the game to keep the game in sync.
+	 */
+	int flib_netconn_send_engineMessage(flib_netconn *conn, const uint8_t *message, size_t size);
+
+	/**
+	 * Inform the server that the round has ended. Call this when the engine has disconnected,
+	 * passing 1 if the round ended normally, 0 otherwise.
+	 */
+	int flib_netconn_send_roundfinished(flib_netconn *conn, bool withoutError);
+
+
+
+
+
+// Callbacks that are important for connecting/disconnecting
+
+	/**
+	 * onNickTaken is called when connecting to the server, if it turns out that there is already a
+	 * player with the same nick.
+	 * In order to proceed, a new nickname needs to be sent to the server using
+	 * flib_netconn_send_nick() (or of course you can bail out and send a QUIT).
+	 * If you don't set a callback, the netconn will automatically react by generating a new name.
+	 */
+	void flib_netconn_onNickTaken(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
+
+	/**
+	 * When connecting with a registered nickname, the server will ask for a password before
+	 * admitting you in. This callback is called when that happens. As a reaction, you can send the
+	 * password using flib_netconn_send_password. If you don't register a callback, the default
+	 * behavior is to just quit in a way that will cause a disconnect with
+	 * NETCONN_DISCONNECT_AUTH_FAILED.
+	 *
+	 * You can't just choose a new nickname when you receive this callback, because at that point
+	 * the server has already accepted your nick.
+	 */
+	void flib_netconn_onPasswordRequest(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
+
+	/**
+	 * This is called when the server has accepted our nickname (and possibly password) and we have
+	 * entered the lobby.
+	 */
+	void flib_netconn_onConnected(flib_netconn *conn, void (*callback)(void *context), void* context);
+
+	/**
+	 * This is always the last callback (unless the netconn is destroyed early), and the netconn
+	 * should be destroyed when it is received. The reason for the disconnect is passed as one of
+	 * the NETCONN_DISCONNECT_ constants. Sometimes a message is included as well, but that
+	 * parameter might also be NULL.
+	 */
+	void flib_netconn_onDisconnected(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void* context);
+
+
+// Callbacks that make sense in most situations
+
+	/**
+	 * Callback for several informational messages that should be displayed to the user
+	 * (e.g. in the chat window), but do not require a reaction. If a game is running, you might
+	 * want to redirect some of these messages to the engine as well so the user will see them.
+	 */
+	void flib_netconn_onMessage(flib_netconn *conn, void (*callback)(void *context, int msgtype, const char *msg), void* context);
+
+	/**
+	 * We received a chat message. Where this message belongs depends on the current state
+	 * (lobby/room). If a game is running the message should be passed to the engine.
+	 */
+	void flib_netconn_onChat(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *msg), void* context);
+
+	/**
+	 * Callbacks for incremental room list updates. They will fire whenever these events occur,
+	 * even before you first query the actual roomlist - so be sure not to blindly reference your
+	 * room list in these callbacks. The server currently only sends updates when a room changes
+	 * its name, so in order to update other room information you need to query the roomlist again
+	 * (see send_request_roomlist / onRoomlist).
+	 */
+	void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_room *room), void* context);
+	void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context);
+	void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_room *room), void* context);
+
+	/**
+	 * Callbacks for players joining or leaving the lobby. In contrast to the roomlist updates, you
+	 * will get a JOIN callback for every player already on the server when you join (and there is
+	 * no direct way to query the current playerlist)
+	 *
+	 * NOTE: partMessage may be NULL.
+	 */
+	void flib_netconn_onLobbyJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
+	void flib_netconn_onLobbyLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context);
+
+	/**
+	 * This is called when the server informs us that one or more flags associated with a
+	 * player/client have changed.
+	 *
+	 * nick is the name of the player, flags is a string containing one character for each modified
+	 * flag (see below), and newFlagState signals whether the flags should be set to true or false.
+	 *
+	 * Some of these flags are important for protocol purposes (especially if they are set for you)
+	 * while others are just informational. Also, some flags are only relevant for players who are
+	 * in the same room as you, and the server will not inform you if they change for others.
+	 *
+	 * These are the currently known/used flags:
+	 * a: Server admin. Always updated.
+	 * h: Room chief. Updated when in the same room.
+	 * r: Ready to play. Updated when in the same room.
+	 * u: Registered user. Always updated.
+	 *
+	 * The server tells us the 'a' and 'u' flags for all players when we first join the lobby, and
+	 * also tells us the 'r' and 'h' flags when we join or create a room. It assumes that all flags
+	 * are initially false, so it will typically only tell you to set certain flags to true when
+	 * transmitting the initial states. Reset the 'h' and 'r' flags to false when leaving a room,
+	 * or when entering room state, to arrive at the right state for each player.
+	 *
+	 * The room chief state of yourself is particularly important because it determines whether you
+	 * can modify settings of the current room. Generally, when you create a room you start out
+	 * being room chief, and when you join an existing room you are not. However, if the original
+	 * chief leaves a room, the server can choose a new chief, and if that happens the chief flag
+	 * will be transferred to someone else.
+	 */
+	void flib_netconn_onClientFlags(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *flags, bool newFlagState), void *context);
+
+// Callbacks that happen only in response to specific requests
+
+	/**
+	 * Response to flib_netconn_send_request_roomlist().
+	 * The rooms array contains the current state of all rooms on the server.
+	 */
+	void flib_netconn_onRoomlist(flib_netconn *conn, void (*callback)(void *context, const flib_room **rooms, int roomCount), void* context);
+
+	/**
+	 * Response to flib_netconn_send_joinRoom, flib_netconn_send_playerFollow or
+	 * flib_netconn_send_createRoom.
+	 *
+	 * You just left the lobby and entered a room.
+	 * If chief is true, you can and should send a full configuration for the room now. This
+	 * consists of ammo, scheme, script and map, where map apparently has to come last.
+	 */
+	void flib_netconn_onEnterRoom(flib_netconn *conn, void (*callback)(void *context, bool chief), void *context);
+
+	/**
+	 * Response to flib_netconn_send_addTeam.
+	 * The server might reject your team for several reasons, e.g. because it has the same name as
+	 * an existing team, or because the room chief restricted adding new teams. If the team is
+	 * accepted by the server, this callback is fired.
+	 *
+	 * If you are the room chief, you are expected to provide the hog count for your own team now
+	 * using flib_netconn_send_teamHogCount. The color of the team is already set to the one you
+	 * provided in addTeam.
+	 */
+	void flib_netconn_onTeamAccepted(flib_netconn *conn, void (*callback)(void *context, const char *team), void *context);
+
+	/**
+	 * When you query the server vars with flib_netconn_send_getServerVars (only works as admin),
+	 * the server replies with a list of them. This callback is called for each entry in that list.
+	 */
+	void flib_netconn_onServerVar(flib_netconn *conn, void (*callback)(void *context, const char *name, const char *value), void *context);
+
+
+// Callbacks that are only relevant in a room
+
+	/**
+	 * You just left a room and entered the lobby again.
+	 * reason is one of the NETCONN_ROOMLEAVE_ constants (usually a kick).
+	 * This will not be called when you actively leave a room using PART.
+	 * Don't confuse with onRoomLeave, which indicates that *someone else* left the room.
+	 */
+	void flib_netconn_onLeaveRoom(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void *context);
+
+	/**
+	 * Someone joined or left the room you are currently in.
+	 * Analogous to onLobbyJoin/leave, you will receive the join callback for all players that are
+	 * already in the room when you join, including for yourself (this is actually how it is
+	 * determined that you joined a room).
+	 *
+	 * However, you will *not* receive onRoomLeave messages for everyone when you leave the room.
+	 */
+	void flib_netconn_onRoomJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context);
+	void flib_netconn_onRoomLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context);
+
+	/**
+	 * A new team was added to the room. The person who adds a team does NOT receive this callback
+	 * (he gets onTeamAccepted instead).
+	 *
+	 * The team does not contain bindings, stats, weaponset, color or the number of hogs (but it is
+	 * assumed to be the default of 4).
+	 *
+	 * If you receive this message and you are the room chief, you may want to send a color and hog
+	 * count for this team using flib_netconn_send_teamHogCount / teamColor for QtFrontend
+	 * compatibility.
+	 *
+	 * The server currently sends another message with the color of the team to the same recipients
+	 * as this teamAdd message, which will trigger an onTeamColorChanged callback. See the
+	 * description of flib_netconn_send_addTeam for more information.
+	 */
+	void flib_netconn_onTeamAdd(flib_netconn *conn, void (*callback)(void *context, const flib_team *team), void *context);
+
+	/**
+	 * A team was removed from the room. The person who removed the team will not receive this
+	 * callback.
+	 */
+	void flib_netconn_onTeamDelete(flib_netconn *conn, void (*callback)(void *context, const char *teamname), void *context);
+
+	/**
+	 * The number of hogs in a team has been changed by the room chief. If you are the chief and
+	 * change the number of hogs yourself, you will not receive this callback.
+	 */
+	void flib_netconn_onHogCountChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int hogs), void *context);
+
+	/**
+	 * The color of a team has been set or changed. The client who set or changed the color will
+	 * not receive this callback.
+	 *
+	 * Normally, only the chief can change the color of a team. However, this message is also
+	 * generated when a team is added, so you can receive it even as chief.
+	 */
+	void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int colorIndex), void *context);
+
+	/**
+	 * The room chief has changed the game scheme (or you just joined a room).
+	 * You will not receive this callback if you changed the scheme yourself.
+	 */
+	void flib_netconn_onSchemeChanged(flib_netconn *conn, void (*callback)(void *context, const flib_scheme *scheme), void *context);
+
+	/**
+	 * The room chief has changed the map (or you just joined a room). Only non-chiefs receive these
+	 * messages.
+	 *
+	 * To reduce the number of callback functions, the netconn keeps track of the current map
+	 * settings and always passes the entire current map config, but informs the callee about what
+	 * has changed (see the NETCONN_MAPCHANGE_ constants).
+	 *
+	 * Caution: Due to the way the protocol works, the map might not be complete at this point if it
+	 * is a hand-drawn map, because the "full" map config does not include the drawn map data.
+	 */
+	void flib_netconn_onMapChanged(flib_netconn *conn, void (*callback)(void *context, const flib_map *map, int changetype), void *context);
+
+	/**
+	 * The room chief has changed the game style (or you just joined a room). If you are the chief
+	 * and change the style yourself, you will not receive this callback.
+	 */
+	void flib_netconn_onScriptChanged(flib_netconn *conn, void (*callback)(void *context, const char *script), void *context);
+
+	/**
+	 * The room chief has changed the weaponset (or you just joined a room). If you are the chief
+	 * and change the weaponset yourself, you will not receive this callback.
+	 */
+	void flib_netconn_onWeaponsetChanged(flib_netconn *conn, void (*callback)(void *context, const flib_weaponset *weaponset), void *context);
+
+	/**
+	 * The game is starting. Fire up the engine and join in!
+	 * You can let the netconn generate the right game setup using flib_netconn_create_gamesetup
+	 */
+	void flib_netconn_onRunGame(flib_netconn *conn, void (*callback)(void *context), void *context);
+
+	/**
+	 * You are in a room, a game is in progress, and the server is sending you the new input for the
+	 * engine to keep up to date with the current happenings. Pass it on to the engine using
+	 * flib_gameconn_send_enginemsg.
+	 */
+	void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const uint8_t *message, size_t size), void *context);
+
+#endif
--- a/project_files/frontlib/net/netconn_internal.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/frontlib/net/netconn_internal.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,151 +1,151 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-/**
- * Common definitions needed by netconn functions, to allow splitting them into several files.
- */
-
-#ifndef NETCONN_INTERNAL_H_
-#define NETCONN_INTERNAL_H_
-
-#include "netconn.h"
-#include "netbase.h"
-#include "../model/map.h"
-#include "../model/team.h"
-#include "../model/weapon.h"
-#include "../model/room.h"
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stddef.h>
-
-struct _flib_netconn {
-    flib_netbase *netBase;
-    char *playerName;
-    char *dataDirPath;
-
-    int netconnState;           //!< One of the NETCONN_STATE constants
-
-    bool isChief;               //!< Player can modify the current room
-    flib_map *map;
-    flib_teamlist pendingTeamlist;
-    flib_teamlist teamlist;
-    flib_scheme *scheme;
-    char *style;
-    flib_weaponset *weaponset;
-
-    void (*onMessageCb)(void *context, int msgtype, const char *msg);
-    void *onMessageCtx;
-
-    void (*onConnectedCb)(void *context);
-    void *onConnectedCtx;
-
-    void (*onDisconnectedCb)(void *context, int reason, const char *message);
-    void *onDisconnectedCtx;
-
-    void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount);
-    void *onRoomlistCtx;
-
-    void (*onRoomAddCb)(void *context, const flib_room *room);
-    void *onRoomAddCtx;
-
-    void (*onRoomDeleteCb)(void *context, const char *name);
-    void *onRoomDeleteCtx;
-
-    void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room);
-    void *onRoomUpdateCtx;
-
-    void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState);
-    void *onClientFlagsCtx;
-
-    void (*onChatCb)(void *context, const char *nick, const char *msg);
-    void *onChatCtx;
-
-    void (*onLobbyJoinCb)(void *context, const char *nick);
-    void *onLobbyJoinCtx;
-
-    void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage);
-    void *onLobbyLeaveCtx;
-
-    void (*onRoomJoinCb)(void *context, const char *nick);
-    void *onRoomJoinCtx;
-
-    void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage);
-    void *onRoomLeaveCtx;
-
-    void (*onNickTakenCb)(void *context, const char *nick);
-    void *onNickTakenCtx;
-
-    void (*onPasswordRequestCb)(void *context, const char *nick);
-    void *onPasswordRequestCtx;
-
-    void (*onEnterRoomCb)(void *context, bool chief);
-    void *onEnterRoomCtx;
-
-    void (*onLeaveRoomCb)(void *context, int reason, const char *message);
-    void *onLeaveRoomCtx;
-
-    void (*onTeamAddCb)(void *context, const flib_team *team);
-    void *onTeamAddCtx;
-
-    void (*onTeamDeleteCb)(void *context, const char *teamname);
-    void *onTeamDeleteCtx;
-
-    void (*onRunGameCb)(void *context);
-    void *onRunGameCtx;
-
-    void (*onTeamAcceptedCb)(void *context, const char *teamName);
-    void *onTeamAcceptedCtx;
-
-    void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs);
-    void *onHogCountChangedCtx;
-
-    void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex);
-    void *onTeamColorChangedCtx;
-
-    void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size);
-    void *onEngineMessageCtx;
-
-    void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme);
-    void *onSchemeChangedCtx;
-
-    void (*onMapChangedCb)(void *context, const flib_map *map, int changetype);
-    void *onMapChangedCtx;
-
-    void (*onScriptChangedCb)(void *context, const char *script);
-    void *onScriptChangedCtx;
-
-    void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset);
-    void *onWeaponsetChangedCtx;
-
-    void (*onServerVarCb)(void *context, const char *name, const char *value);
-    void *onServerVarCtx;
-
-    bool running;
-    bool destroyRequested;
-};
-
-void netconn_clearCallbacks(flib_netconn *conn);
-void netconn_leaveRoom(flib_netconn *conn);
-void netconn_setMap(flib_netconn *conn, const flib_map *map);
-void netconn_setWeaponset(flib_netconn *conn, const flib_weaponset *weaponset);
-void netconn_setScript(flib_netconn *conn, const char *script);
-void netconn_setScheme(flib_netconn *conn, const flib_scheme *scheme);
-
-#endif
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * Common definitions needed by netconn functions, to allow splitting them into several files.
+ */
+
+#ifndef NETCONN_INTERNAL_H_
+#define NETCONN_INTERNAL_H_
+
+#include "netconn.h"
+#include "netbase.h"
+#include "../model/map.h"
+#include "../model/team.h"
+#include "../model/weapon.h"
+#include "../model/room.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+
+struct _flib_netconn {
+	flib_netbase *netBase;
+	char *playerName;
+	char *dataDirPath;
+
+	int netconnState;			//!< One of the NETCONN_STATE constants
+
+	bool isChief;				//!< Player can modify the current room
+	flib_map *map;
+	flib_teamlist pendingTeamlist;
+	flib_teamlist teamlist;
+	flib_scheme *scheme;
+	char *style;
+	flib_weaponset *weaponset;
+
+	void (*onMessageCb)(void *context, int msgtype, const char *msg);
+	void *onMessageCtx;
+
+	void (*onConnectedCb)(void *context);
+	void *onConnectedCtx;
+
+	void (*onDisconnectedCb)(void *context, int reason, const char *message);
+	void *onDisconnectedCtx;
+
+	void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount);
+	void *onRoomlistCtx;
+
+	void (*onRoomAddCb)(void *context, const flib_room *room);
+	void *onRoomAddCtx;
+
+	void (*onRoomDeleteCb)(void *context, const char *name);
+	void *onRoomDeleteCtx;
+
+	void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room);
+	void *onRoomUpdateCtx;
+
+	void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState);
+	void *onClientFlagsCtx;
+
+	void (*onChatCb)(void *context, const char *nick, const char *msg);
+	void *onChatCtx;
+
+	void (*onLobbyJoinCb)(void *context, const char *nick);
+	void *onLobbyJoinCtx;
+
+	void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage);
+	void *onLobbyLeaveCtx;
+
+	void (*onRoomJoinCb)(void *context, const char *nick);
+	void *onRoomJoinCtx;
+
+	void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage);
+	void *onRoomLeaveCtx;
+
+	void (*onNickTakenCb)(void *context, const char *nick);
+	void *onNickTakenCtx;
+
+	void (*onPasswordRequestCb)(void *context, const char *nick);
+	void *onPasswordRequestCtx;
+
+	void (*onEnterRoomCb)(void *context, bool chief);
+	void *onEnterRoomCtx;
+
+	void (*onLeaveRoomCb)(void *context, int reason, const char *message);
+	void *onLeaveRoomCtx;
+
+	void (*onTeamAddCb)(void *context, const flib_team *team);
+	void *onTeamAddCtx;
+
+	void (*onTeamDeleteCb)(void *context, const char *teamname);
+	void *onTeamDeleteCtx;
+
+	void (*onRunGameCb)(void *context);
+	void *onRunGameCtx;
+
+	void (*onTeamAcceptedCb)(void *context, const char *teamName);
+	void *onTeamAcceptedCtx;
+
+	void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs);
+	void *onHogCountChangedCtx;
+
+	void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex);
+	void *onTeamColorChangedCtx;
+
+	void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size);
+	void *onEngineMessageCtx;
+
+	void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme);
+	void *onSchemeChangedCtx;
+
+	void (*onMapChangedCb)(void *context, const flib_map *map, int changetype);
+	void *onMapChangedCtx;
+
+	void (*onScriptChangedCb)(void *context, const char *script);
+	void *onScriptChangedCtx;
+
+	void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset);
+	void *onWeaponsetChangedCtx;
+
+	void (*onServerVarCb)(void *context, const char *name, const char *value);
+	void *onServerVarCtx;
+
+	bool running;
+	bool destroyRequested;
+};
+
+void netconn_clearCallbacks(flib_netconn *conn);
+void netconn_leaveRoom(flib_netconn *conn);
+void netconn_setMap(flib_netconn *conn, const flib_map *map);
+void netconn_setWeaponset(flib_netconn *conn, const flib_weaponset *weaponset);
+void netconn_setScript(flib_netconn *conn, const char *script);
+void netconn_setScheme(flib_netconn *conn, const flib_scheme *scheme);
+
+#endif
--- a/project_files/hwc/rtl/SysUtils.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/SysUtils.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,41 +1,41 @@
-#ifndef _FPCRTL_SYSUTILS_H_
-#define _FPCRTL_SYSUTILS_H_
-
-#include "Types.h"
-
-// EFFECTS: return the current date time in pascal notation
-//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
-TDateTime   fpcrtl_now();
-#define     now                     fpcrtl_now
-#define     Now                     fpcrtl_now
-
-// EFFECTS: return the current time
-//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
-TDateTime   fpcrtl_time();
-
-
-// EFFECTS: return the current date
-//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
-TDateTime   fpcrtl_date();
-#define     date                    fpcrtl_date
-#define     Date                    fpcrtl_date
-
-// EFFECTS: Trim strips blank characters (spaces) at the beginning and end of S
-// and returns the resulting string. Only #32 characters are stripped.
-// If the string contains only spaces, an empty string is returned.
-string255   fpcrtl_trim(string255 s);
-#define     trim                    fpcrtl_trim
-#define     Trim                    fpcrtl_trim
-
-Integer     fpcrtl_strToInt(string255 s);
-#define     StrToInt                fpcrtl_strToInt
-#define     strToInt                fpcrtl_strToInt
-
-string255   fpcrtl_extractFileName(string255 f);
-#define     fpcrtl_ExtractFileName  fpcrtl_extractFileName
-
-string255   fpcrtl_strPas(PChar);
-#define     fpcrtl_StrPas           fpcrtl_strPas
-
-
-#endif
+#ifndef _FPCRTL_SYSUTILS_H_
+#define _FPCRTL_SYSUTILS_H_
+
+#include "Types.h"
+
+// EFFECTS: return the current date time in pascal notation
+//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
+TDateTime   fpcrtl_now();
+#define     now                     fpcrtl_now
+#define     Now                     fpcrtl_now
+
+// EFFECTS: return the current time
+//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
+TDateTime   fpcrtl_time();
+
+
+// EFFECTS: return the current date
+//          http://www.merlyn.demon.co.uk/del-prgg.htm#TDT
+TDateTime   fpcrtl_date();
+#define     date                    fpcrtl_date
+#define     Date                    fpcrtl_date
+
+// EFFECTS: Trim strips blank characters (spaces) at the beginning and end of S
+// and returns the resulting string. Only #32 characters are stripped.
+// If the string contains only spaces, an empty string is returned.
+string255   fpcrtl_trim(string255 s);
+#define     trim                    fpcrtl_trim
+#define     Trim                    fpcrtl_trim
+
+Integer     fpcrtl_strToInt(string255 s);
+#define     StrToInt                fpcrtl_strToInt
+#define     strToInt                fpcrtl_strToInt
+
+string255   fpcrtl_extractFileName(string255 f);
+#define     fpcrtl_ExtractFileName  fpcrtl_extractFileName
+
+string255   fpcrtl_strPas(PChar);
+#define     fpcrtl_StrPas           fpcrtl_strPas
+
+
+#endif
--- a/project_files/hwc/rtl/Types.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/Types.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,39 +1,39 @@
-#ifndef _TYPES_H_
-#define _TYPES_H_
-
-#include "pas2c.h"
-
-/*
- * Not very useful currently
- */
-
-typedef double TDate;
-typedef double TTime;
-typedef double TDateTime;
-typedef string255 TMonthNameArray[13];
-typedef string255 TWeekNameArray[8];
-
-typedef struct {
-    Byte CurrencyFormat;
-    Byte NegCurrFormat;
-    Char ThousandSeparator;
-    Char DecimalSeparator;
-    Byte CurrencyDecimals;
-    Char DateSeparator;
-    Char TimeSeparator;
-    Char ListSeparator;
-    string255 CurrencyString;
-    string255 ShortDateFormat;
-    string255 LongDateFormat;
-    string255 TimeAMString;
-    string255 TimePMString;
-    string255 ShortTimeFormat;
-    string255 LongTimeFormat;
-    TMonthNameArray ShortMonthNames;
-    TMonthNameArray LongMonthNames;
-    TWeekNameArray ShortDayNames;
-    TWeekNameArray LongDayNames;
-    Word TwoDigitYearCenturyWindow;
-}TFormatSettings;
-
-#endif
+#ifndef _TYPES_H_
+#define _TYPES_H_
+
+#include "pas2c.h"
+
+/*
+ * Not very useful currently
+ */
+
+typedef double TDate;
+typedef double TTime;
+typedef double TDateTime;
+typedef string255 TMonthNameArray[13];
+typedef string255 TWeekNameArray[8];
+
+typedef struct {
+    Byte CurrencyFormat;
+    Byte NegCurrFormat;
+    Char ThousandSeparator;
+    Char DecimalSeparator;
+    Byte CurrencyDecimals;
+    Char DateSeparator;
+    Char TimeSeparator;
+    Char ListSeparator;
+    string255 CurrencyString;
+    string255 ShortDateFormat;
+    string255 LongDateFormat;
+    string255 TimeAMString;
+    string255 TimePMString;
+    string255 ShortTimeFormat;
+    string255 LongTimeFormat;
+    TMonthNameArray ShortMonthNames;
+    TMonthNameArray LongMonthNames;
+    TWeekNameArray ShortDayNames;
+    TWeekNameArray LongDayNames;
+    Word TwoDigitYearCenturyWindow;
+}TFormatSettings;
+
+#endif
--- a/project_files/hwc/rtl/fpcrtl.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/fpcrtl.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,202 +1,202 @@
-#ifndef _FPCRTL_H_
-#define _FPCRTL_H_
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-
-#include "SysUtils.h"
-#include "system.h"
-#include "misc.h"
-#include "fileio.h"
-#include "pmath.h"
-
-#ifndef EMSCRIPTEN
-#if __APPLE__
-#define main SDL_main
-#endif
-#include "GL/glew.h"
-#endif
-
-#define fpcrtl_memcpy                       memcpy
-
-#define luapas_lua_gettop                   lua_gettop
-#define luapas_lua_close                    lua_close
-#define luapas_lua_createtable              lua_createtable
-#define luapas_lua_error                    lua_error
-#define luapas_lua_gc                       lua_gc
-#define luapas_lua_getfield                 lua_getfield
-#define luapas_lua_objlen                   lua_objlen
-#define luapas_lua_call                     lua_call
-#define luapas_lua_pcall                    lua_pcall
-#define luapas_lua_pushboolean              lua_pushboolean
-#define luapas_lua_pushcclosure             lua_pushcclosure
-#define luapas_lua_pushinteger              lua_pushinteger
-#define luapas_lua_pushnil                  lua_pushnil
-#define luapas_lua_pushnumber               lua_pushnumber
-#define luapas_lua_pushlstring              lua_pushlstring
-#define luapas_lua_pushstring               lua_pushstring
-#define luapas_lua_pushvalue                lua_pushvalue
-#define luapas_lua_rawgeti                  lua_rawgeti
-#define luapas_lua_setfield                 lua_setfield
-#define luapas_lua_settop                   lua_settop
-#define luapas_lua_toboolean                lua_toboolean
-#define luapas_lua_tointeger                lua_tointeger
-#define luapas_lua_tolstring                lua_tolstring
-#define luapas_lua_tonumber                 lua_tonumber
-#define luapas_lua_type                     lua_type
-#define luapas_lua_typename                 lua_typename
-#define luapas_luaL_argerror                luaL_argerror
-#define luapas_luaL_checkinteger            luaL_checkinteger
-#define luapas_luaL_checklstring            luaL_checklstring
-#define luapas_luaL_loadfile                luaL_loadfile
-#define luapas_luaL_loadstring              luaL_loadstring
-#define luapas_luaL_newstate                luaL_newstate
-#define luapas_luaL_optinteger              luaL_optinteger
-#define luapas_luaL_optlstring              luaL_optlstring
-#define luapas_luaL_prepbuffer              luaL_prepbuffer
-#define luapas_luaL_ref                     luaL_ref
-#define luapas_luaL_unref                   luaL_unref
-#define luapas_luaopen_base                 luaopen_base
-#define luapas_luaopen_math                 luaopen_math
-#define luapas_luaopen_string               luaopen_string
-#define luapas_luaopen_table                luaopen_table
-#define luapas_lua_load                     lua_load
-
-#define sdlh_IMG_Load                       IMG_Load
-#define sdlh_IMG_Load_RW                    IMG_Load_RW
-
-#ifndef EMSCRIPTEN
-#define sdlh_Mix_AllocateChannels           Mix_AllocateChannels
-#define sdlh_Mix_CloseAudio                 Mix_CloseAudio
-#define sdlh_Mix_FadeInChannelTimed         Mix_FadeInChannelTimed
-#define sdlh_Mix_FadeInMusic                Mix_FadeInMusic
-#define sdlh_Mix_FadeOutChannel             Mix_FadeOutChannel
-#define sdlh_Mix_FreeChunk                  Mix_FreeChunk
-#define sdlh_Mix_FreeMusic                  Mix_FreeMusic
-#define sdlh_Mix_HaltChannel                Mix_HaltChannel
-#define sdlh_Mix_HaltMusic                  Mix_HaltMusic
-#define sdlh_Mix_LoadMUS                    Mix_LoadMUS
-#define sdlh_Mix_LoadMUS_RW                 Mix_LoadMUS_RW
-#define sdlh_Mix_LoadWAV_RW                 Mix_LoadWAV_RW
-#define sdlh_Mix_OpenAudio                  Mix_OpenAudio
-#define sdlh_Mix_PauseMusic                 Mix_PauseMusic
-#define sdlh_Mix_PlayChannelTimed           Mix_PlayChannelTimed
-#define sdlh_Mix_Playing                    Mix_Playing
-#define sdlh_Mix_ResumeMusic                Mix_ResumeMusic
-#define sdlh_Mix_Volume                     Mix_Volume
-#define sdlh_Mix_VolumeMusic                Mix_VolumeMusic
-#else
-#define sdlh_Mix_AllocateChannels           stub_Mix_AllocateChannels
-#define sdlh_Mix_CloseAudio                 stub_Mix_CloseAudio
-#define sdlh_Mix_FadeInChannelTimed         stub_Mix_FadeInChannelTimed
-#define sdlh_Mix_FadeInMusic                stub_Mix_FadeInMusic
-#define sdlh_Mix_FadeOutChannel             stub_Mix_FadeOutChannel
-#define sdlh_Mix_FreeChunk                  stub_Mix_FreeChunk
-#define sdlh_Mix_FreeMusic                  stub_Mix_FreeMusic
-#define sdlh_Mix_HaltChannel                stub_Mix_HaltChannel
-#define sdlh_Mix_HaltMusic                  stub_Mix_HaltMusic
-#define sdlh_Mix_LoadMUS                    stub_Mix_LoadMUS
-#define sdlh_Mix_LoadMUS_RW                 stub_Mix_LoadMUS_RW
-#define sdlh_Mix_LoadWAV_RW                 stub_Mix_LoadWAV_RW
-#define sdlh_Mix_OpenAudio                  stub_Mix_OpenAudio
-#define sdlh_Mix_PauseMusic                 stub_Mix_PauseMusic
-#define sdlh_Mix_PlayChannelTimed           stub_Mix_PlayChannelTimed
-#define sdlh_Mix_Playing                    stub_Mix_Playing
-#define sdlh_Mix_ResumeMusic                stub_Mix_ResumeMusic
-#define sdlh_Mix_Volume                     stub_Mix_Volume
-#define sdlh_Mix_VolumeMusic                stub_Mix_VolumeMusic
-#endif
-
-#define sdlh_SDL_ConvertSurface             SDL_ConvertSurface
-#define sdlh_SDL_CreateRGBSurface           SDL_CreateRGBSurface
-#define sdlh_SDL_CreateThread               SDL_CreateThread
-#define sdlh_SDL_Delay                      SDL_Delay
-#define sdlh_SDL_EnableKeyRepeat            SDL_EnableKeyRepeat
-#define sdlh_SDL_EnableUNICODE              SDL_EnableUNICODE
-#define sdlh_SDL_FillRect                   SDL_FillRect
-#define sdlh_SDL_FreeSurface                SDL_FreeSurface
-#define sdlh_SDL_GetError                   SDL_GetError
-#define sdlh_SDL_GetKeyName                 SDL_GetKeyName
-#define sdlh_SDL_GetKeyState                SDL_GetKeyState
-#define sdlh_SDL_GetMouseState              SDL_GetMouseState
-#define sdlh_SDL_GetRGBA                    SDL_GetRGBA
-#define sdlh_SDL_GetTicks                   SDL_GetTicks
-#define sdlh_SDL_GL_SetAttribute            SDL_GL_SetAttribute
-#define sdlh_SDL_GL_SwapBuffers             SDL_GL_SwapBuffers
-#define sdlh_SDL_Init                       SDL_Init
-#define sdlh_SDL_InitSubSystem              SDL_InitSubSystem
-#define sdlh_SDL_JoystickClose              SDL_JoystickClose
-#define sdlh_SDL_JoystickEventState         SDL_JoystickEventState
-#define sdlh_SDL_JoystickName               SDL_JoystickName
-#define sdlh_SDL_JoystickNumAxes            SDL_JoystickNumAxes
-#define sdlh_SDL_JoystickNumButtons         SDL_JoystickNumButtons
-#define sdlh_SDL_JoystickNumHats            SDL_JoystickNumHats
-#define sdlh_SDL_JoystickOpen               SDL_JoystickOpen
-#define sdlh_SDL_LockSurface                SDL_LockSurface
-#define sdlh_SDL_MapRGB                     SDL_MapRGB
-#define sdlh_SDL_MapRGBA                    SDL_MapRGBA
-#define sdlh_SDL_NumJoysticks               SDL_NumJoysticks
-#define sdlh_SDL_PeepEvents                 SDL_PeepEvents
-#define sdlh_SDL_PumpEvents                 SDL_PumpEvents
-#define sdlh_SDL_Quit                       SDL_Quit
-#define sdlh_SDL_RWFromFile                 SDL_RWFromFile
-#define sdlh_SDL_SetColorKey                SDL_SetColorKey
-#define sdlh_SDL_SetVideoMode               SDL_SetVideoMode
-#define sdlh_SDL_WaitThread                 SDL_WaitThread
-#define sdlh_SDL_CreateMutex                SDL_CreateMutex
-#define sdlh_SDL_DestroyMutex               SDL_DestroyMutex
-#define sdlh_SDL_LockMutex                  SDL_mutexP
-#define sdlh_SDL_UnlockMutex                SDL_mutexV
-#ifndef EMSCRIPTEN
-#define sdlh_SDL_ShowCursor                 SDL_ShowCursor
-#else
-#define sdlh_SDL_ShowCursor                 SDL_ShowCursor_patch
-#endif
-#define sdlh_SDL_UnlockSurface              SDL_UnlockSurface
-#define sdlh_SDL_UpperBlit                  SDL_UpperBlit
-#define sdlh_SDL_VideoDriverName            SDL_VideoDriverName
-#define sdlh_SDL_WarpMouse                  SDL_WarpMouse
-#define sdlh_SDL_WM_SetCaption              SDL_WM_SetCaption
-#define sdlh_SDL_WM_SetIcon                 SDL_WM_SetIcon
-#define sdlh_SDLNet_AddSocket               SDLNet_AddSocket
-#define sdlh_SDLNet_AllocSocketSet          SDLNet_AllocSocketSet
-#define sdlh_SDLNet_CheckSockets            SDLNet_CheckSockets
-#define sdlh_SDLNet_FreeSocketSet           SDLNet_FreeSocketSet
-#define sdlh_SDLNet_Init                    SDLNet_Init
-#define sdlh_SDLNet_Quit                    SDLNet_Quit
-#define sdlh_SDLNet_ResolveHost             SDLNet_ResolveHost
-#define sdlh_SDLNet_TCP_Close               SDLNet_TCP_Close
-#define sdlh_SDLNet_TCP_Open                SDLNet_TCP_Open
-#define sdlh_SDLNet_TCP_Recv                SDLNet_TCP_Recv
-#define sdlh_SDLNet_TCP_Send                SDLNet_TCP_Send
-#define sdlh_TTF_Init                       TTF_Init
-#define sdlh_TTF_OpenFont                   TTF_OpenFont
-#define sdlh_TTF_OpenFontRW                 TTF_OpenFontRW
-#define sdlh_TTF_Quit                       TTF_Quit
-#define sdlh_TTF_RenderUTF8_Blended         TTF_RenderUTF8_Blended
-#define sdlh_TTF_RenderUTF8_Solid           TTF_RenderUTF8_Solid
-#define sdlh_TTF_SetFontStyle               TTF_SetFontStyle
-#define sdlh_TTF_SizeUTF8                   TTF_SizeUTF8
-
-#define _strconcat                          fpcrtl_strconcat
-#define _strappend                          fpcrtl_strappend
-#define _strprepend                         fpcrtl_strprepend
-#define _strcompare                         fpcrtl_strcompare
-#define _strncompare                        fpcrtl_strncompare
-#define _strcomparec                        fpcrtl_strcomparec
-#define _chrconcat                          fpcrtl_chrconcat
-#define _pchar                              fpcrtl_pchar
-
-// hooks are implemented in javascript
-void start_hook(void);
-void mainloop_hook(void);
-void clear_filelist_hook(void);
-void add_file_hook(const char* ptr);
-void idb_loader_hook();
-void showcursor_hook();
-void hidecursor_hook();
-void drawworld_init_hook();
-#endif
+#ifndef _FPCRTL_H_
+#define _FPCRTL_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+
+#include "SysUtils.h"
+#include "system.h"
+#include "misc.h"
+#include "fileio.h"
+#include "pmath.h"
+
+#ifndef EMSCRIPTEN
+#if __APPLE__
+#define main SDL_main
+#endif
+#include "GL/glew.h"
+#endif
+
+#define fpcrtl_memcpy                       memcpy
+
+#define luapas_lua_gettop                   lua_gettop
+#define luapas_lua_close                    lua_close
+#define luapas_lua_createtable              lua_createtable
+#define luapas_lua_error                    lua_error
+#define luapas_lua_gc                       lua_gc
+#define luapas_lua_getfield                 lua_getfield
+#define luapas_lua_objlen                   lua_objlen
+#define luapas_lua_call                     lua_call
+#define luapas_lua_pcall                    lua_pcall
+#define luapas_lua_pushboolean              lua_pushboolean
+#define luapas_lua_pushcclosure             lua_pushcclosure
+#define luapas_lua_pushinteger              lua_pushinteger
+#define luapas_lua_pushnil                  lua_pushnil
+#define luapas_lua_pushnumber               lua_pushnumber
+#define luapas_lua_pushlstring              lua_pushlstring
+#define luapas_lua_pushstring               lua_pushstring
+#define luapas_lua_pushvalue                lua_pushvalue
+#define luapas_lua_rawgeti                  lua_rawgeti
+#define luapas_lua_setfield                 lua_setfield
+#define luapas_lua_settop                   lua_settop
+#define luapas_lua_toboolean                lua_toboolean
+#define luapas_lua_tointeger                lua_tointeger
+#define luapas_lua_tolstring                lua_tolstring
+#define luapas_lua_tonumber                 lua_tonumber
+#define luapas_lua_type                     lua_type
+#define luapas_lua_typename                 lua_typename
+#define luapas_luaL_argerror                luaL_argerror
+#define luapas_luaL_checkinteger            luaL_checkinteger
+#define luapas_luaL_checklstring            luaL_checklstring
+#define luapas_luaL_loadfile                luaL_loadfile
+#define luapas_luaL_loadstring              luaL_loadstring
+#define luapas_luaL_newstate                luaL_newstate
+#define luapas_luaL_optinteger              luaL_optinteger
+#define luapas_luaL_optlstring              luaL_optlstring
+#define luapas_luaL_prepbuffer              luaL_prepbuffer
+#define luapas_luaL_ref                     luaL_ref
+#define luapas_luaL_unref                   luaL_unref
+#define luapas_luaopen_base                 luaopen_base
+#define luapas_luaopen_math                 luaopen_math
+#define luapas_luaopen_string               luaopen_string
+#define luapas_luaopen_table                luaopen_table
+#define luapas_lua_load                     lua_load
+
+#define sdlh_IMG_Load                       IMG_Load
+#define sdlh_IMG_Load_RW                    IMG_Load_RW
+
+#ifndef EMSCRIPTEN
+#define sdlh_Mix_AllocateChannels           Mix_AllocateChannels
+#define sdlh_Mix_CloseAudio                 Mix_CloseAudio
+#define sdlh_Mix_FadeInChannelTimed         Mix_FadeInChannelTimed
+#define sdlh_Mix_FadeInMusic                Mix_FadeInMusic
+#define sdlh_Mix_FadeOutChannel             Mix_FadeOutChannel
+#define sdlh_Mix_FreeChunk                  Mix_FreeChunk
+#define sdlh_Mix_FreeMusic                  Mix_FreeMusic
+#define sdlh_Mix_HaltChannel                Mix_HaltChannel
+#define sdlh_Mix_HaltMusic                  Mix_HaltMusic
+#define sdlh_Mix_LoadMUS                    Mix_LoadMUS
+#define sdlh_Mix_LoadMUS_RW                 Mix_LoadMUS_RW
+#define sdlh_Mix_LoadWAV_RW                 Mix_LoadWAV_RW
+#define sdlh_Mix_OpenAudio                  Mix_OpenAudio
+#define sdlh_Mix_PauseMusic                 Mix_PauseMusic
+#define sdlh_Mix_PlayChannelTimed           Mix_PlayChannelTimed
+#define sdlh_Mix_Playing                    Mix_Playing
+#define sdlh_Mix_ResumeMusic                Mix_ResumeMusic
+#define sdlh_Mix_Volume                     Mix_Volume
+#define sdlh_Mix_VolumeMusic                Mix_VolumeMusic
+#else
+#define sdlh_Mix_AllocateChannels           stub_Mix_AllocateChannels
+#define sdlh_Mix_CloseAudio                 stub_Mix_CloseAudio
+#define sdlh_Mix_FadeInChannelTimed         stub_Mix_FadeInChannelTimed
+#define sdlh_Mix_FadeInMusic                stub_Mix_FadeInMusic
+#define sdlh_Mix_FadeOutChannel             stub_Mix_FadeOutChannel
+#define sdlh_Mix_FreeChunk                  stub_Mix_FreeChunk
+#define sdlh_Mix_FreeMusic                  stub_Mix_FreeMusic
+#define sdlh_Mix_HaltChannel                stub_Mix_HaltChannel
+#define sdlh_Mix_HaltMusic                  stub_Mix_HaltMusic
+#define sdlh_Mix_LoadMUS                    stub_Mix_LoadMUS
+#define sdlh_Mix_LoadMUS_RW                 stub_Mix_LoadMUS_RW
+#define sdlh_Mix_LoadWAV_RW                 stub_Mix_LoadWAV_RW
+#define sdlh_Mix_OpenAudio                  stub_Mix_OpenAudio
+#define sdlh_Mix_PauseMusic                 stub_Mix_PauseMusic
+#define sdlh_Mix_PlayChannelTimed           stub_Mix_PlayChannelTimed
+#define sdlh_Mix_Playing                    stub_Mix_Playing
+#define sdlh_Mix_ResumeMusic                stub_Mix_ResumeMusic
+#define sdlh_Mix_Volume                     stub_Mix_Volume
+#define sdlh_Mix_VolumeMusic                stub_Mix_VolumeMusic
+#endif
+
+#define sdlh_SDL_ConvertSurface             SDL_ConvertSurface
+#define sdlh_SDL_CreateRGBSurface           SDL_CreateRGBSurface
+#define sdlh_SDL_CreateThread               SDL_CreateThread
+#define sdlh_SDL_Delay                      SDL_Delay
+#define sdlh_SDL_EnableKeyRepeat            SDL_EnableKeyRepeat
+#define sdlh_SDL_EnableUNICODE              SDL_EnableUNICODE
+#define sdlh_SDL_FillRect                   SDL_FillRect
+#define sdlh_SDL_FreeSurface                SDL_FreeSurface
+#define sdlh_SDL_GetError                   SDL_GetError
+#define sdlh_SDL_GetKeyName                 SDL_GetKeyName
+#define sdlh_SDL_GetKeyState                SDL_GetKeyState
+#define sdlh_SDL_GetMouseState              SDL_GetMouseState
+#define sdlh_SDL_GetRGBA                    SDL_GetRGBA
+#define sdlh_SDL_GetTicks                   SDL_GetTicks
+#define sdlh_SDL_GL_SetAttribute            SDL_GL_SetAttribute
+#define sdlh_SDL_GL_SwapBuffers             SDL_GL_SwapBuffers
+#define sdlh_SDL_Init                       SDL_Init
+#define sdlh_SDL_InitSubSystem              SDL_InitSubSystem
+#define sdlh_SDL_JoystickClose              SDL_JoystickClose
+#define sdlh_SDL_JoystickEventState         SDL_JoystickEventState
+#define sdlh_SDL_JoystickName               SDL_JoystickName
+#define sdlh_SDL_JoystickNumAxes            SDL_JoystickNumAxes
+#define sdlh_SDL_JoystickNumButtons         SDL_JoystickNumButtons
+#define sdlh_SDL_JoystickNumHats            SDL_JoystickNumHats
+#define sdlh_SDL_JoystickOpen               SDL_JoystickOpen
+#define sdlh_SDL_LockSurface                SDL_LockSurface
+#define sdlh_SDL_MapRGB                     SDL_MapRGB
+#define sdlh_SDL_MapRGBA                    SDL_MapRGBA
+#define sdlh_SDL_NumJoysticks               SDL_NumJoysticks
+#define sdlh_SDL_PeepEvents                 SDL_PeepEvents
+#define sdlh_SDL_PumpEvents                 SDL_PumpEvents
+#define sdlh_SDL_Quit                       SDL_Quit
+#define sdlh_SDL_RWFromFile                 SDL_RWFromFile
+#define sdlh_SDL_SetColorKey                SDL_SetColorKey
+#define sdlh_SDL_SetVideoMode               SDL_SetVideoMode
+#define sdlh_SDL_WaitThread                 SDL_WaitThread
+#define sdlh_SDL_CreateMutex                SDL_CreateMutex
+#define sdlh_SDL_DestroyMutex               SDL_DestroyMutex
+#define sdlh_SDL_LockMutex                  SDL_mutexP
+#define sdlh_SDL_UnlockMutex                SDL_mutexV
+#ifndef EMSCRIPTEN
+#define sdlh_SDL_ShowCursor                 SDL_ShowCursor
+#else
+#define sdlh_SDL_ShowCursor                 SDL_ShowCursor_patch
+#endif
+#define sdlh_SDL_UnlockSurface              SDL_UnlockSurface
+#define sdlh_SDL_UpperBlit                  SDL_UpperBlit
+#define sdlh_SDL_VideoDriverName            SDL_VideoDriverName
+#define sdlh_SDL_WarpMouse                  SDL_WarpMouse
+#define sdlh_SDL_WM_SetCaption              SDL_WM_SetCaption
+#define sdlh_SDL_WM_SetIcon                 SDL_WM_SetIcon
+#define sdlh_SDLNet_AddSocket               SDLNet_AddSocket
+#define sdlh_SDLNet_AllocSocketSet          SDLNet_AllocSocketSet
+#define sdlh_SDLNet_CheckSockets            SDLNet_CheckSockets
+#define sdlh_SDLNet_FreeSocketSet           SDLNet_FreeSocketSet
+#define sdlh_SDLNet_Init                    SDLNet_Init
+#define sdlh_SDLNet_Quit                    SDLNet_Quit
+#define sdlh_SDLNet_ResolveHost             SDLNet_ResolveHost
+#define sdlh_SDLNet_TCP_Close               SDLNet_TCP_Close
+#define sdlh_SDLNet_TCP_Open                SDLNet_TCP_Open
+#define sdlh_SDLNet_TCP_Recv                SDLNet_TCP_Recv
+#define sdlh_SDLNet_TCP_Send                SDLNet_TCP_Send
+#define sdlh_TTF_Init                       TTF_Init
+#define sdlh_TTF_OpenFont                   TTF_OpenFont
+#define sdlh_TTF_OpenFontRW                 TTF_OpenFontRW
+#define sdlh_TTF_Quit                       TTF_Quit
+#define sdlh_TTF_RenderUTF8_Blended         TTF_RenderUTF8_Blended
+#define sdlh_TTF_RenderUTF8_Solid           TTF_RenderUTF8_Solid
+#define sdlh_TTF_SetFontStyle               TTF_SetFontStyle
+#define sdlh_TTF_SizeUTF8                   TTF_SizeUTF8
+
+#define _strconcat                          fpcrtl_strconcat
+#define _strappend                          fpcrtl_strappend
+#define _strprepend                         fpcrtl_strprepend
+#define _strcompare                         fpcrtl_strcompare
+#define _strncompare                        fpcrtl_strncompare
+#define _strcomparec                        fpcrtl_strcomparec
+#define _chrconcat                          fpcrtl_chrconcat
+#define _pchar                              fpcrtl_pchar
+
+// hooks are implemented in javascript
+void start_hook(void);
+void mainloop_hook(void);
+void clear_filelist_hook(void);
+void add_file_hook(const char* ptr);
+void idb_loader_hook();
+void showcursor_hook();
+void hidecursor_hook();
+void drawworld_init_hook();
+#endif
--- a/project_files/hwc/rtl/misc.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/misc.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,168 +1,168 @@
-#include "misc.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-
-char strbuf[512];
-
-void fpcrtl_assert(int i)
-{
-    if(!i){
-        assert(0);
-    }
-}
-
-// EFFECTS: return the nearest integer of the given number
-int fpcrtl_round(double number)
-{
-    return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
-}
-
-void fpcrtl_printf(const char* format, ...)
-{
-#ifdef FPCRTL_DEBUG
-    va_list args;
-    va_start (args, format);
-    vprintf (format, args);
-    va_end (args);
-#endif
-}
-
-//
-//void fpcrtl_check_string(string255 str)
-//{
-//#ifdef FPCRTL_DEBUG
-//    int len = strlen(str.str);
-//    if(len != str.len){
-//        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", str.str, len, str.len);
-//    }
-//    //assert(len == str.len);
-//#endif
-//}
-
-string255 fpcrtl_strconcat(string255 str1, string255 str2)
-{
-    //printf("str1 = %d, %d\n", str1.len, strlen(str1.str));
-    //printf("str2 = %d, %d\n", str2.len, strlen(str2.str));
-
-#ifdef FPCRTL_DEBUG
-    if(str1.len + (int)(str2.len) > 255){
-        printf("String overflow\n");
-        printf("str1(%d): %s\nstr2(%d): %s\n", str1.len, str1.str, str2.len, str2.str);
-        printf("String will be truncated.\n");
-
-        strbuf[0] = 0;
-        strcpy(strbuf, str1.str);
-        strcat(strbuf, str2.str);
-        memcpy(str1.str, strbuf, 255);
-        str1.str[254] = 0;
-
-        return str1;
-    }
-#endif
-
-    memcpy(&(str1.str[str1.len]), str2.str, str2.len);
-    str1.str[str1.len + str2.len] = 0;
-    str1.len += str2.len;
-
-    return str1;
-}
-
-string255 fpcrtl_strappend(string255 s, char c)
-{
-    s.str[s.len] = c;
-    s.str[s.len + 1] = 0;
-    s.len ++;
-
-    return s;
-}
-
-string255 fpcrtl_strprepend(char c, string255 s)
-{
-    FIX_STRING(s);
-
-    memmove(s.str + 1, s.str, s.len + 1); // also move '/0'
-    s.str[0] = c;
-    s.len++;
-
-    return s;
-}
-
-string255 fpcrtl_chrconcat(char a, char b)
-{
-    string255 result;
-
-    result.len = 2;
-    result.str[0] = a;
-    result.str[1] = b;
-    result.str[2] = 0;
-
-    return result;
-}
-
-bool fpcrtl_strcompare(string255 str1, string255 str2)
-{
-    //printf("str1 = %d, %d\n", str1.len, strlen(str1.str));
-    //printf("str2 = %d, %d\n", str2.len, strlen(str2.str));
-    FIX_STRING(str1);
-    FIX_STRING(str2);
-
-    if(strcmp(str1.str, str2.str) == 0){
-        return true;
-    }
-
-    return false;
-}
-
-bool fpcrtl_strcomparec(string255 a, char b)
-{
-    FIX_STRING(a);
-
-    if(a.len == 1 && a.str[0] == b){
-        return true;
-    }
-
-    return false;
-}
-
-bool fpcrtl_strncompare(string255 a, string255 b)
-{
-    return !fpcrtl_strcompare(a, b);
-}
-
-//char* fpcrtl_pchar(string255 s)
-//{
-//    return s.str;
-//}
-
-string255 fpcrtl_pchar2str(char *s)
-{
-    string255 result;
-    int t = strlen(s);
-
-    if(t > 255){
-        printf("pchar2str, length > 255\n");
-        assert(0);
-    }
-
-    result.len = t;
-    memcpy(result.str, s, t);
-    result.str[t] = 0;
-
-    return result;
-}
-
-string255 fpcrtl_make_string(const char* s) {
-    string255 result;
-    strcpy(result.str, s);
-    result.len = strlen(s);
-    return result;
-}
-
-#ifdef EMSCRIPTEN
-GLenum glewInit()
-{
-    return GLEW_OK;
-}
-#endif
+#include "misc.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <assert.h>
+
+char strbuf[512];
+
+void fpcrtl_assert(int i)
+{
+    if(!i){
+        assert(0);
+    }
+}
+
+// EFFECTS: return the nearest integer of the given number
+int fpcrtl_round(double number)
+{
+    return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
+}
+
+void fpcrtl_printf(const char* format, ...)
+{
+#ifdef FPCRTL_DEBUG
+    va_list args;
+    va_start (args, format);
+    vprintf (format, args);
+    va_end (args);
+#endif
+}
+
+//
+//void fpcrtl_check_string(string255 str)
+//{
+//#ifdef FPCRTL_DEBUG
+//    int len = strlen(str.str);
+//    if(len != str.len){
+//        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", str.str, len, str.len);
+//    }
+//    //assert(len == str.len);
+//#endif
+//}
+
+string255 fpcrtl_strconcat(string255 str1, string255 str2)
+{
+    //printf("str1 = %d, %d\n", str1.len, strlen(str1.str));
+    //printf("str2 = %d, %d\n", str2.len, strlen(str2.str));
+
+#ifdef FPCRTL_DEBUG
+    if(str1.len + (int)(str2.len) > 255){
+        printf("String overflow\n");
+        printf("str1(%d): %s\nstr2(%d): %s\n", str1.len, str1.str, str2.len, str2.str);
+        printf("String will be truncated.\n");
+
+        strbuf[0] = 0;
+        strcpy(strbuf, str1.str);
+        strcat(strbuf, str2.str);
+        memcpy(str1.str, strbuf, 255);
+        str1.str[254] = 0;
+
+        return str1;
+    }
+#endif
+
+    memcpy(&(str1.str[str1.len]), str2.str, str2.len);
+    str1.str[str1.len + str2.len] = 0;
+    str1.len += str2.len;
+
+    return str1;
+}
+
+string255 fpcrtl_strappend(string255 s, char c)
+{
+    s.str[s.len] = c;
+    s.str[s.len + 1] = 0;
+    s.len ++;
+
+    return s;
+}
+
+string255 fpcrtl_strprepend(char c, string255 s)
+{
+    FIX_STRING(s);
+
+    memmove(s.str + 1, s.str, s.len + 1); // also move '/0'
+    s.str[0] = c;
+    s.len++;
+
+    return s;
+}
+
+string255 fpcrtl_chrconcat(char a, char b)
+{
+    string255 result;
+
+    result.len = 2;
+    result.str[0] = a;
+    result.str[1] = b;
+    result.str[2] = 0;
+
+    return result;
+}
+
+bool fpcrtl_strcompare(string255 str1, string255 str2)
+{
+    //printf("str1 = %d, %d\n", str1.len, strlen(str1.str));
+    //printf("str2 = %d, %d\n", str2.len, strlen(str2.str));
+    FIX_STRING(str1);
+    FIX_STRING(str2);
+
+    if(strcmp(str1.str, str2.str) == 0){
+        return true;
+    }
+
+    return false;
+}
+
+bool fpcrtl_strcomparec(string255 a, char b)
+{
+    FIX_STRING(a);
+
+    if(a.len == 1 && a.str[0] == b){
+        return true;
+    }
+
+    return false;
+}
+
+bool fpcrtl_strncompare(string255 a, string255 b)
+{
+    return !fpcrtl_strcompare(a, b);
+}
+
+//char* fpcrtl_pchar(string255 s)
+//{
+//    return s.str;
+//}
+
+string255 fpcrtl_pchar2str(char *s)
+{
+    string255 result;
+    int t = strlen(s);
+
+    if(t > 255){
+        printf("pchar2str, length > 255\n");
+        assert(0);
+    }
+
+    result.len = t;
+    memcpy(result.str, s, t);
+    result.str[t] = 0;
+
+    return result;
+}
+
+string255 fpcrtl_make_string(const char* s) {
+    string255 result;
+    strcpy(result.str, s);
+    result.len = strlen(s);
+    return result;
+}
+
+#ifdef EMSCRIPTEN
+GLenum glewInit()
+{
+    return GLEW_OK;
+}
+#endif
--- a/project_files/hwc/rtl/misc.h	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/misc.h	Tue Jan 21 22:38:13 2014 +0100
@@ -1,58 +1,58 @@
-#ifndef _FPCRTL_MISC_H_
-#define _FPCRTL_MISC_H_
-
-#include "pas2c.h"
-#include <assert.h>
-#include <stdbool.h>
-
-#ifdef EMSCRIPTEN
-#include <GL/gl.h>
-#else
-#include <GL/glew.h>
-#endif
-
-#define     VA_NUM_ARGS(...)                        VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
-#define     VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...)  N
-
-#define     macro_dispatcher(func, ...)             macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
-#define     macro_dispatcher_(func, nargs)          macro_dispatcher__(func, nargs)
-#define     macro_dispatcher__(func, nargs)         func ## nargs
-
-#define     FPCRTL_DEBUG
-
-#define     FIX_STRING(s)                           (s.str[s.len] = 0)
-
-//#define fpcrtl_check_string(s)     do{ if(strlen((s).str) != (s).len){ \
-//                                        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \
-//                                        assert(0);\
-//                                    }}while(0)
-
-void        fpcrtl_assert(int);
-void        fpcrtl_print_trace (void);
-
-int         fpcrtl_round(double number);
-void        fpcrtl_printf(const char* format, ...);
-
-string255   fpcrtl_make_string(const char* s);
-
-string255   fpcrtl_strconcat(string255 str1, string255 str2);
-string255   fpcrtl_strappend(string255 s, char c);
-string255   fpcrtl_strprepend(char c, string255 s);
-string255   fpcrtl_chrconcat(char a, char b);
-
-// return true if str1 == str2
-bool        fpcrtl_strcompare(string255 str1, string255 str2);
-bool        fpcrtl_strcomparec(string255 a, char b);
-bool        fpcrtl_strncompare(string255 a, string255 b);
-
-#define     fpcrtl__pchar(s)                        ((s).str)
-string255   fpcrtl_pchar2str(char *s);
-
-#define     fpcrtl_TypeInfo                         sizeof // dummy
-
-#ifdef EMSCRIPTEN
-#define     GLEW_OK                                 1
-GLenum      glewInit();
-#endif
-
-#endif
+#ifndef _FPCRTL_MISC_H_
+#define _FPCRTL_MISC_H_
+
+#include "pas2c.h"
+#include <assert.h>
+#include <stdbool.h>
+
+#ifdef EMSCRIPTEN
+#include <GL/gl.h>
+#else
+#include <GL/glew.h>
+#endif
+
+#define     VA_NUM_ARGS(...)                        VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
+#define     VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...)  N
+
+#define     macro_dispatcher(func, ...)             macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
+#define     macro_dispatcher_(func, nargs)          macro_dispatcher__(func, nargs)
+#define     macro_dispatcher__(func, nargs)         func ## nargs
+
+#define     FPCRTL_DEBUG
+
+#define     FIX_STRING(s)                           (s.str[s.len] = 0)
+
+//#define fpcrtl_check_string(s)     do{ if(strlen((s).str) != (s).len){ \
+//                                        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \
+//                                        assert(0);\
+//                                    }}while(0)
+
+void        fpcrtl_assert(int);
+void        fpcrtl_print_trace (void);
+
+int         fpcrtl_round(double number);
+void        fpcrtl_printf(const char* format, ...);
+
+string255   fpcrtl_make_string(const char* s);
+
+string255   fpcrtl_strconcat(string255 str1, string255 str2);
+string255   fpcrtl_strappend(string255 s, char c);
+string255   fpcrtl_strprepend(char c, string255 s);
+string255   fpcrtl_chrconcat(char a, char b);
+
+// return true if str1 == str2
+bool        fpcrtl_strcompare(string255 str1, string255 str2);
+bool        fpcrtl_strcomparec(string255 a, char b);
+bool        fpcrtl_strncompare(string255 a, string255 b);
+
+#define     fpcrtl__pchar(s)                        ((s).str)
+string255   fpcrtl_pchar2str(char *s);
+
+#define     fpcrtl_TypeInfo                         sizeof // dummy
+
+#ifdef EMSCRIPTEN
+#define     GLEW_OK                                 1
+GLenum      glewInit();
+#endif
+
+#endif
--- a/project_files/hwc/rtl/sysutils.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/sysutils.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,178 +1,178 @@
-#include "SysUtils.h"
-
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "system.h"
-#include "misc.h"
-
-TDateTime fpcrtl_date()
-{
-    const int num_days_between_1900_1980 = 29220;
-
-    struct tm ref_date;
-    struct tm cur_date;
-    time_t local_time;
-    time_t ref_time, cur_time;
-
-    double timeDiff;
-    double day_time_frac; //fraction that represents the time in one day
-    int num_seconds;
-    int numDays;
-    
-    // unix epoch doesn't work, choose Jan 1st 1980 instead
-    ref_date.tm_year = 80;
-    ref_date.tm_mon = 0;
-    ref_date.tm_mday = 1;
-    ref_date.tm_hour = 0;
-    ref_date.tm_min = 0;
-    ref_date.tm_sec = 0;
-    ref_date.tm_isdst = 0;
-    ref_date.tm_wday = 0; // ignored
-    ref_date.tm_yday = 0; // ignored
-
-    local_time = time(NULL);
-    cur_date = *localtime(&local_time);
-
-    cur_date.tm_hour = 0;
-    cur_date.tm_min = 0;
-    cur_date.tm_sec = 0;
-
-    ref_time = mktime(&ref_date);
-    cur_time = mktime(&cur_date);
-
-    timeDiff = difftime(cur_time, ref_time);
-    numDays = fpcrtl_round(timeDiff / 3600 / 24) + num_days_between_1900_1980 + 1;
-
-    fpcrtl_printf("[date] tim diff: %f\n", timeDiff);
-    fpcrtl_printf("[date] num days between 1980 and today:  %d\n", fpcrtl_round(timeDiff/3600/24));
-    fpcrtl_printf("[date] current date: %s\n", asctime(&cur_date));
-    fpcrtl_printf("[date] reference date: %s\n", asctime(&ref_date));
-    fpcrtl_printf("[date] num days: %d\n", numDays);
-    
-    return numDays;
-}
-
-TDateTime fpcrtl_time()
-{
-    struct tm cur_date;
-    time_t local_time;
-    time_t cur_time;
-
-    double day_time_frac; //fraction that represents the time in one day
-    int num_seconds;
-    
-    local_time = time(NULL);
-    cur_date = *localtime(&local_time);
-
-    num_seconds = cur_date.tm_hour * 3600 + cur_date.tm_min * 60 + cur_date.tm_sec;
-    day_time_frac = num_seconds / 3600.0 / 24.0;
-
-    fpcrtl_printf("%f\n", day_time_frac);
-
-    return day_time_frac;
-}
-
-TDateTime fpcrtl_now()
-{
-    return fpcrtl_date() + fpcrtl_time();
-}
-
-/*
- * XXX: dummy
- */
-string255 fpcrtl_formatDateTime(string255 FormatStr, TDateTime DateTime)
-{
-    string255 result = STRINIT("2012 01-01");
-    return result;
-}
-
-string255 fpcrtl_trim(string255 s)
-{
-    int left, right;
-
-    if(s.len == 0){
-        return s;
-    }
-
-    for(left = 0; left < s.len; left++)
-    {
-        if(s.str[left] != ' '){
-            break;
-        }
-    }
-
-    for(right = s.len - 1; right >= 0; right--)
-    {
-        if(s.str[right] != ' '){
-            break;
-        }
-    }
-
-    if(left > right){
-        s.len = 0;
-        s.str[0] = 0;
-        return s;
-    }
-
-    s.len = right - left + 1;
-    memmove(s.str, s.str + left, s.len);
-
-    s.str[s.len] = 0;
-
-    return s;
-}
-
-Integer fpcrtl_strToInt(string255 s)
-{
-    s.str[s.len] = 0;
-    return atoi(s.str);
-}
-
-//function ExtractFileName(const FileName: string): string;
-//var
-//  i : longint;
-//  EndSep : Set of Char;
-//begin
-//  I := Length(FileName);
-//  EndSep:=AllowDirectorySeparators+AllowDriveSeparators;
-//  while (I > 0) and not (FileName[I] in EndSep) do
-//    Dec(I);
-//  Result := Copy(FileName, I + 1, MaxInt);
-//end;
-
-string255 fpcrtl_extractFileName(string255 f)
-{
-    const char sep[] = {'\\', '/', ':'};
-    LongInt i,j;
-
-    i = f.len - 1;
-    while(i >= 0){
-        for(j = 0; j < sizeof(sep); j++){
-            if(f.str[i] == sep[j]){
-                goto FPCRTL_EXTRACTFILENAME_END;
-            }
-        }
-        i--;
-    }
-FPCRTL_EXTRACTFILENAME_END:
-    return fpcrtl_copy(f, i + 2, 256);
-}
-
-string255 fpcrtl_strPas(PChar p)
-{
-    string255 s;
-    int l = strlen(p);
-
-    if(l > 255){
-        printf("strPas: source string length > 255\n");
-        assert(0);
-    }
-
-    s.len = l;
-    strcpy(s.str, p);
-
-    return s;
-}
+#include "SysUtils.h"
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "system.h"
+#include "misc.h"
+
+TDateTime fpcrtl_date()
+{
+    const int num_days_between_1900_1980 = 29220;
+
+    struct tm ref_date;
+    struct tm cur_date;
+    time_t local_time;
+    time_t ref_time, cur_time;
+
+    double timeDiff;
+    double day_time_frac; //fraction that represents the time in one day
+    int num_seconds;
+    int numDays;
+
+    // unix epoch doesn't work, choose Jan 1st 1980 instead
+    ref_date.tm_year = 80;
+    ref_date.tm_mon = 0;
+    ref_date.tm_mday = 1;
+    ref_date.tm_hour = 0;
+    ref_date.tm_min = 0;
+    ref_date.tm_sec = 0;
+    ref_date.tm_isdst = 0;
+    ref_date.tm_wday = 0; // ignored
+    ref_date.tm_yday = 0; // ignored
+
+    local_time = time(NULL);
+    cur_date = *localtime(&local_time);
+
+    cur_date.tm_hour = 0;
+    cur_date.tm_min = 0;
+    cur_date.tm_sec = 0;
+
+    ref_time = mktime(&ref_date);
+    cur_time = mktime(&cur_date);
+
+    timeDiff = difftime(cur_time, ref_time);
+    numDays = fpcrtl_round(timeDiff / 3600 / 24) + num_days_between_1900_1980 + 1;
+
+    fpcrtl_printf("[date] tim diff: %f\n", timeDiff);
+    fpcrtl_printf("[date] num days between 1980 and today:  %d\n", fpcrtl_round(timeDiff/3600/24));
+    fpcrtl_printf("[date] current date: %s\n", asctime(&cur_date));
+    fpcrtl_printf("[date] reference date: %s\n", asctime(&ref_date));
+    fpcrtl_printf("[date] num days: %d\n", numDays);
+
+    return numDays;
+}
+
+TDateTime fpcrtl_time()
+{
+    struct tm cur_date;
+    time_t local_time;
+    time_t cur_time;
+
+    double day_time_frac; //fraction that represents the time in one day
+    int num_seconds;
+
+    local_time = time(NULL);
+    cur_date = *localtime(&local_time);
+
+    num_seconds = cur_date.tm_hour * 3600 + cur_date.tm_min * 60 + cur_date.tm_sec;
+    day_time_frac = num_seconds / 3600.0 / 24.0;
+
+    fpcrtl_printf("%f\n", day_time_frac);
+
+    return day_time_frac;
+}
+
+TDateTime fpcrtl_now()
+{
+    return fpcrtl_date() + fpcrtl_time();
+}
+
+/*
+ * XXX: dummy
+ */
+string255 fpcrtl_formatDateTime(string255 FormatStr, TDateTime DateTime)
+{
+    string255 result = STRINIT("2012 01-01");
+    return result;
+}
+
+string255 fpcrtl_trim(string255 s)
+{
+    int left, right;
+
+    if(s.len == 0){
+        return s;
+    }
+
+    for(left = 0; left < s.len; left++)
+    {
+        if(s.str[left] != ' '){
+            break;
+        }
+    }
+
+    for(right = s.len - 1; right >= 0; right--)
+    {
+        if(s.str[right] != ' '){
+            break;
+        }
+    }
+
+    if(left > right){
+        s.len = 0;
+        s.str[0] = 0;
+        return s;
+    }
+
+    s.len = right - left + 1;
+    memmove(s.str, s.str + left, s.len);
+
+    s.str[s.len] = 0;
+
+    return s;
+}
+
+Integer fpcrtl_strToInt(string255 s)
+{
+    s.str[s.len] = 0;
+    return atoi(s.str);
+}
+
+//function ExtractFileName(const FileName: string): string;
+//var
+//  i : longint;
+//  EndSep : Set of Char;
+//begin
+//  I := Length(FileName);
+//  EndSep:=AllowDirectorySeparators+AllowDriveSeparators;
+//  while (I > 0) and not (FileName[I] in EndSep) do
+//    Dec(I);
+//  Result := Copy(FileName, I + 1, MaxInt);
+//end;
+
+string255 fpcrtl_extractFileName(string255 f)
+{
+    const char sep[] = {'\\', '/', ':'};
+    LongInt i,j;
+
+    i = f.len - 1;
+    while(i >= 0){
+        for(j = 0; j < sizeof(sep); j++){
+            if(f.str[i] == sep[j]){
+                goto FPCRTL_EXTRACTFILENAME_END;
+            }
+        }
+        i--;
+    }
+FPCRTL_EXTRACTFILENAME_END:
+    return fpcrtl_copy(f, i + 2, 256);
+}
+
+string255 fpcrtl_strPas(PChar p)
+{
+    string255 s;
+    int l = strlen(p);
+
+    if(l > 255){
+        printf("strPas: source string length > 255\n");
+        assert(0);
+    }
+
+    s.len = l;
+    strcpy(s.str, p);
+
+    return s;
+}
--- a/project_files/hwc/rtl/tests/check_check.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/check_check.c	Tue Jan 21 22:38:13 2014 +0100
@@ -4,20 +4,20 @@
 
 int main(void)
 {
-	int number_failed;
+    int number_failed;
 
-	Suite *s1 = system_suite();
-	Suite *s2 = misc_suite();
-	Suite *s3 = sysutils_suite();
-	Suite *s4 = fileio_suite();
+    Suite *s1 = system_suite();
+    Suite *s2 = misc_suite();
+    Suite *s3 = sysutils_suite();
+    Suite *s4 = fileio_suite();
 
-	SRunner *sr = srunner_create(s1);
-	srunner_add_suite(sr, s2);
-	srunner_add_suite(sr, s3);
-	srunner_add_suite(sr, s4);
+    SRunner *sr = srunner_create(s1);
+    srunner_add_suite(sr, s2);
+    srunner_add_suite(sr, s3);
+    srunner_add_suite(sr, s4);
 
-	srunner_run_all(sr, CK_NORMAL);
-	number_failed = srunner_ntests_failed(sr);
-	srunner_free(sr);
-	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
--- a/project_files/hwc/rtl/tests/check_fileio.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/check_fileio.c	Tue Jan 21 22:38:13 2014 +0100
@@ -6,8 +6,8 @@
 
 typedef struct __TResourceList
 {
-	Integer count;
-	string255 files[500 + 1];
+    Integer count;
+    string255 files[500 + 1];
 } TResourceList;
 
 string255 t = STRINIT("test");
@@ -22,82 +22,82 @@
 
 static string255 make_string(const char* str)
 {
-	string255 s;
-	s.len = strlen(str);
-	memcpy(s.str, str, s.len + 1);
-	return s;
+    string255 s;
+    s.len = strlen(str);
+    memcpy(s.str, str, s.len + 1);
+    return s;
 }
 
 TResourceList readThemeCfg_0()
 {
-	TResourceList readthemecfg_result;
-	string255 s;
-	string255 key;
-	TextFile f;
-	Integer i;
-	TResourceList res;
+    TResourceList readthemecfg_result;
+    string255 s;
+    string255 key;
+    TextFile f;
+    Integer i;
+    TResourceList res;
 
-	s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
-	//umisc_log(s);
+    s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
+    //umisc_log(s);
 
-	fpcrtl_assign(f, s);
+    fpcrtl_assign(f, s);
 
-	FileMode = 0;
-	fpcrtl_reset(f);
+    FileMode = 0;
+    fpcrtl_reset(f);
 
-	res.count = 0;
-	while (!(fpcrtl_eof(f)))
-	{
-		fpcrtl_readLnS(f, s);
-		if ((fpcrtl_Length(s)) == (0))
-		{
-			continue;
-		}
-		if ((s.s[1]) == ('\x3b'))
-		{
-			continue;
-		}
-		i = fpcrtl_pos('\x3d', s);
-		key = fpcrtl_trim(fpcrtl_copy(s, 1, i - 1));
-		fpcrtl_delete(s, 1, i);
-		if (_strcompare(key, __str79))
-		{
-			i = fpcrtl_pos('\x2c', s);
-			res.files[res.count] = _strconcat(
-					_strappend(Pathz[ptCurrTheme], '\x2f'),
-					fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
-			++res.count;
-			//umisc_log(fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
-		}
-	}
-	fpcrtl_close(f);
-	readthemecfg_result = res;
-	return readthemecfg_result;
+    res.count = 0;
+    while (!(fpcrtl_eof(f)))
+    {
+        fpcrtl_readLnS(f, s);
+        if ((fpcrtl_Length(s)) == (0))
+        {
+            continue;
+        }
+        if ((s.s[1]) == ('\x3b'))
+        {
+            continue;
+        }
+        i = fpcrtl_pos('\x3d', s);
+        key = fpcrtl_trim(fpcrtl_copy(s, 1, i - 1));
+        fpcrtl_delete(s, 1, i);
+        if (_strcompare(key, __str79))
+        {
+            i = fpcrtl_pos('\x2c', s);
+            res.files[res.count] = _strconcat(
+                    _strappend(Pathz[ptCurrTheme], '\x2f'),
+                    fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
+            ++res.count;
+            //umisc_log(fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
+        }
+    }
+    fpcrtl_close(f);
+    readthemecfg_result = res;
+    return readthemecfg_result;
 }
 
 START_TEST(test_readthemecfg)
-	{
-		int i;
-		TResourceList result;
+    {
+        int i;
+        TResourceList result;
 
-		printf("-----Entering test readthemecfg-----\n");
-		result = readThemeCfg_0();
-		for (i = 0; i < result.count; i++)
-		{
-			printf("%s\n", result.files[i].str);
-		}
-		printf("-----Leaving test readthemecfg-----\n");
-	}END_TEST
+        printf("-----Entering test readthemecfg-----\n");
+        result = readThemeCfg_0();
+        for (i = 0; i < result.count; i++)
+        {
+            printf("%s\n", result.files[i].str);
+        }
+        printf("-----Leaving test readthemecfg-----\n");
+    }END_TEST
 
 Suite* fileio_suite(void)
 {
-	Suite *s = suite_create("fileio");
+    Suite *s = suite_create("fileio");
 
-	TCase *tc_core = tcase_create("Core");
+    TCase *tc_core = tcase_create("Core");
 
-	tcase_add_test(tc_core, test_readthemecfg);
+    tcase_add_test(tc_core, test_readthemecfg);
 
-	suite_add_tcase(s, tc_core);
+    suite_add_tcase(s, tc_core);
 
-	return s;
+    return s;
 }
--- a/project_files/hwc/rtl/tests/check_misc.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/check_misc.c	Tue Jan 21 22:38:13 2014 +0100
@@ -6,83 +6,83 @@
 
 static string255 make_string(const char* str)
 {
-	string255 s;
-	s.len = strlen(str);
-	memcpy(s.str, str, s.len + 1);
-	return s;
+    string255 s;
+    s.len = strlen(str);
+    memcpy(s.str, str, s.len + 1);
+    return s;
 }
 
 START_TEST(test_strconcat)
 {
-	string255 t;
-	t = fpcrtl_strconcat(make_string(""), make_string(""));
-	fail_if(strcmp(t.str, ""), "strconcat(\"\", \"\")");
+    string255 t;
+    t = fpcrtl_strconcat(make_string(""), make_string(""));
+    fail_if(strcmp(t.str, ""), "strconcat(\"\", \"\")");
 
-	t = fpcrtl_strconcat(make_string(""), make_string("a"));
-	fail_if(strcmp(t.str, "a"), "strconcat(\"\", \"a\")");
+    t = fpcrtl_strconcat(make_string(""), make_string("a"));
+    fail_if(strcmp(t.str, "a"), "strconcat(\"\", \"a\")");
 
-	t = fpcrtl_strconcat(make_string("a"), make_string(""));
-	fail_if(strcmp(t.str, "a"), "strconcat(\"a\", \"\")");
+    t = fpcrtl_strconcat(make_string("a"), make_string(""));
+    fail_if(strcmp(t.str, "a"), "strconcat(\"a\", \"\")");
 
-	t = fpcrtl_strconcat(make_string("ab"), make_string(""));
-	fail_if(strcmp(t.str, "ab"), "strconcat(\"ab\", \"\")");
+    t = fpcrtl_strconcat(make_string("ab"), make_string(""));
+    fail_if(strcmp(t.str, "ab"), "strconcat(\"ab\", \"\")");
 
-	t = fpcrtl_strconcat(make_string("ab"), make_string("cd"));
-	fail_if(strcmp(t.str, "abcd"), "strconcat(\"ab\", \"cd\")");
+    t = fpcrtl_strconcat(make_string("ab"), make_string("cd"));
+    fail_if(strcmp(t.str, "abcd"), "strconcat(\"ab\", \"cd\")");
 }
 END_TEST
 
 START_TEST (test_strappend)
 {
-	string255 t;
+    string255 t;
 
-	t = fpcrtl_strappend(make_string(""), 'c');
-	fail_if(strcmp(t.str, "c"), "strappend(\"\", 'c')");
+    t = fpcrtl_strappend(make_string(""), 'c');
+    fail_if(strcmp(t.str, "c"), "strappend(\"\", 'c')");
 
-	t = fpcrtl_strappend(make_string("ab"), 'c');
-	fail_if(strcmp(t.str, "abc"), "strappend(\"ab\", 'c')");
+    t = fpcrtl_strappend(make_string("ab"), 'c');
+    fail_if(strcmp(t.str, "abc"), "strappend(\"ab\", 'c')");
 }
 END_TEST
 
 START_TEST (test_strprepend)
 {
-	string255 t;
+    string255 t;
 
-	t = fpcrtl_strprepend('c', make_string(""));
-	fail_if(strcmp(t.str, "c"), "strprepend('c', \"\")");
+    t = fpcrtl_strprepend('c', make_string(""));
+    fail_if(strcmp(t.str, "c"), "strprepend('c', \"\")");
 
-	t = fpcrtl_strprepend('c', make_string("ab"));
-	fail_if(strcmp(t.str, "cab"), "strprepend('c', \"ab\")");
+    t = fpcrtl_strprepend('c', make_string("ab"));
+    fail_if(strcmp(t.str, "cab"), "strprepend('c', \"ab\")");
 }
 END_TEST
 
 START_TEST (test_strcompare)
 {
-	fail_unless(fpcrtl_strcompare(make_string(""), make_string("")), "strcompare(\"\", \"\")");
-	fail_unless(fpcrtl_strcompare(make_string("a"), make_string("a")), "strcompare(\"a\", \"a\"");
-	fail_unless(!fpcrtl_strcompare(make_string("a"), make_string("b")), "strcompare(\"a\", \"b\")");
-	fail_unless(!fpcrtl_strcompare(make_string("a"), make_string("ab")), "strcompare(\"a\", \"ab\")");
+    fail_unless(fpcrtl_strcompare(make_string(""), make_string("")), "strcompare(\"\", \"\")");
+    fail_unless(fpcrtl_strcompare(make_string("a"), make_string("a")), "strcompare(\"a\", \"a\"");
+    fail_unless(!fpcrtl_strcompare(make_string("a"), make_string("b")), "strcompare(\"a\", \"b\")");
+    fail_unless(!fpcrtl_strcompare(make_string("a"), make_string("ab")), "strcompare(\"a\", \"ab\")");
 
-	fail_unless(fpcrtl_strcomparec(make_string(" "), ' '), "strcomparec(\" \", ' ')");
-	fail_unless(fpcrtl_strcomparec(make_string("a"), 'a'), "strcomparec(\"a\", 'a')");
-	fail_unless(!fpcrtl_strcomparec(make_string("  "), ' '), "strcomparec(\"  \", ' '");
-	fail_unless(!fpcrtl_strcomparec(make_string(""), ' '), "strcomparec(\"\", ' ')");
+    fail_unless(fpcrtl_strcomparec(make_string(" "), ' '), "strcomparec(\" \", ' ')");
+    fail_unless(fpcrtl_strcomparec(make_string("a"), 'a'), "strcomparec(\"a\", 'a')");
+    fail_unless(!fpcrtl_strcomparec(make_string("  "), ' '), "strcomparec(\"  \", ' '");
+    fail_unless(!fpcrtl_strcomparec(make_string(""), ' '), "strcomparec(\"\", ' ')");
 
 }
 END_TEST
 
 Suite* misc_suite(void)
 {
-	Suite *s = suite_create("misc");
+    Suite *s = suite_create("misc");
 
-	TCase *tc_core = tcase_create("Core");
+    TCase *tc_core = tcase_create("Core");
 
-	tcase_add_test(tc_core, test_strconcat);
-	tcase_add_test(tc_core, test_strappend);
-	tcase_add_test(tc_core, test_strprepend);
-	tcase_add_test(tc_core, test_strcompare);
+    tcase_add_test(tc_core, test_strconcat);
+    tcase_add_test(tc_core, test_strappend);
+    tcase_add_test(tc_core, test_strprepend);
+    tcase_add_test(tc_core, test_strcompare);
 
-	suite_add_tcase(s, tc_core);
+    suite_add_tcase(s, tc_core);
 
-	return s;
+    return s;
 }
--- a/project_files/hwc/rtl/tests/check_system.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/check_system.c	Tue Jan 21 22:38:13 2014 +0100
@@ -6,246 +6,246 @@
 
 void check_string(string255 str)
 {
-	fail_unless(strlen(str.str) == str.len, "String internal inconsistency error");
+    fail_unless(strlen(str.str) == str.len, "String internal inconsistency error");
 }
 
 static string255 make_string(const char* str)
 {
-	string255 s;
-	s.len = strlen(str);
-	memcpy(s.str, str, s.len + 1);
-	return s;
+    string255 s;
+    s.len = strlen(str);
+    memcpy(s.str, str, s.len + 1);
+    return s;
 }
 
 START_TEST (test_copy)
-	{
-		string255 s = STRINIT("1234567");
-		string255 t;
+    {
+        string255 s = STRINIT("1234567");
+        string255 t;
 
-		t = fpcrtl_copy(s, 1, 1);
-		fail_if(strcmp(t.str, "1"), "Test copy fail 1");
+        t = fpcrtl_copy(s, 1, 1);
+        fail_if(strcmp(t.str, "1"), "Test copy fail 1");
 
-		t = fpcrtl_copy(s, 7, 1);
-		fail_if(strcmp(t.str, "7"), "Test copy fail 2");
+        t = fpcrtl_copy(s, 7, 1);
+        fail_if(strcmp(t.str, "7"), "Test copy fail 2");
 
-		t = fpcrtl_copy(s, 8, 1);
-		fail_if(t.len != 0, "Test copy fail 3");
+        t = fpcrtl_copy(s, 8, 1);
+        fail_if(t.len != 0, "Test copy fail 3");
 
-		t = fpcrtl_copy(s, 8, 100);
-		fail_if(t.len != 0, "Test copy fail 4");
-		check_string(t);
+        t = fpcrtl_copy(s, 8, 100);
+        fail_if(t.len != 0, "Test copy fail 4");
+        check_string(t);
 
-		t = fpcrtl_copy(s, 0, 100);
-		fail_if(strcmp(t.str, "1234567"), "Test copy fail 5");
+        t = fpcrtl_copy(s, 0, 100);
+        fail_if(strcmp(t.str, "1234567"), "Test copy fail 5");
 
-		t = fpcrtl_copy(s, 0, 5);
-		fail_if(strcmp(t.str, "12345"), "Test copy fail 6");
+        t = fpcrtl_copy(s, 0, 5);
+        fail_if(strcmp(t.str, "12345"), "Test copy fail 6");
 
-		t = fpcrtl_copy(s, 4, 100);
-		fail_if(strcmp(t.str, "4567"), "Test copy fail 7");
+        t = fpcrtl_copy(s, 4, 100);
+        fail_if(strcmp(t.str, "4567"), "Test copy fail 7");
 
-		t = fpcrtl_copy(s, 4, 2);
-		fail_if(strcmp(t.str, "45"), "Test copy fail 8");
-	}END_TEST
+        t = fpcrtl_copy(s, 4, 2);
+        fail_if(strcmp(t.str, "45"), "Test copy fail 8");
+    }END_TEST
 
 START_TEST (test_delete)
-	{
-		string255 s = STRINIT("1234567");
-		string255 s2 = STRINIT("1234567");
-		string255 s3 = STRINIT("1234567");
+    {
+        string255 s = STRINIT("1234567");
+        string255 s2 = STRINIT("1234567");
+        string255 s3 = STRINIT("1234567");
 
-		fpcrtl_delete(s, 0, 10);
-		fail_if(strcmp(s.str, "1234567"), "delete(\"1234567\", 0, 10)");
-		check_string(s);
+        fpcrtl_delete(s, 0, 10);
+        fail_if(strcmp(s.str, "1234567"), "delete(\"1234567\", 0, 10)");
+        check_string(s);
 
-		fpcrtl_delete(s, 1, 1);
-		fail_if(strcmp(s.str, "234567"), "delete(\"1234567\", 1, 1)");
-		check_string(s);
+        fpcrtl_delete(s, 1, 1);
+        fail_if(strcmp(s.str, "234567"), "delete(\"1234567\", 1, 1)");
+        check_string(s);
 
-		fpcrtl_delete(s, 1, 100);
-		fail_if(strcmp(s.str, ""), "delete(\"234567\", 1, 100)");
-		check_string(s);
+        fpcrtl_delete(s, 1, 100);
+        fail_if(strcmp(s.str, ""), "delete(\"234567\", 1, 100)");
+        check_string(s);
 
-		fpcrtl_delete(s2, 3, 2);
-		fail_if(strcmp(s2.str, "12567"), "delete(\"1234567\", 3, 2)");
-		check_string(s2);
+        fpcrtl_delete(s2, 3, 2);
+        fail_if(strcmp(s2.str, "12567"), "delete(\"1234567\", 3, 2)");
+        check_string(s2);
 
-		fpcrtl_delete(s3, 3, 100);
-		fail_if(strcmp(s3.str, "12"), "delete(\"1234567\", 3, 100)");
-		check_string(s3);
+        fpcrtl_delete(s3, 3, 100);
+        fail_if(strcmp(s3.str, "12"), "delete(\"1234567\", 3, 100)");
+        check_string(s3);
 
-	}
+    }
 END_TEST
 
 START_TEST (test_FloatToStr)
-	{
-		double s = 1.2345;
-		string255 t = fpcrtl_floatToStr(s);
-		printf("-----Entering test floatToStr-----\n");
-		printf("FloatToStr(%f) = %s\n", s, t.str);
-		printf("-----Leaving test floatToStr-----\n");
-	}
+    {
+        double s = 1.2345;
+        string255 t = fpcrtl_floatToStr(s);
+        printf("-----Entering test floatToStr-----\n");
+        printf("FloatToStr(%f) = %s\n", s, t.str);
+        printf("-----Leaving test floatToStr-----\n");
+    }
 END_TEST
 
 START_TEST (test_random)
-	{
-		fpcrtl_randomize();
-		printf("-----Entering test random-----\n");
-		printf("random(5000) = %d\n", fpcrtl_random(5000));
-		printf("random(1) = %d\n", fpcrtl_random(1));
-		printf("random(2) = %d\n", fpcrtl_random(2));
-		printf("-----Leaving test random-----\n");
+    {
+        fpcrtl_randomize();
+        printf("-----Entering test random-----\n");
+        printf("random(5000) = %d\n", fpcrtl_random(5000));
+        printf("random(1) = %d\n", fpcrtl_random(1));
+        printf("random(2) = %d\n", fpcrtl_random(2));
+        printf("-----Leaving test random-----\n");
 
-	}
+    }
 END_TEST
 
 START_TEST (test_posS)
-	{
-		string255 substr1 = STRINIT("123");
-		string255 str1 = STRINIT("12345");
+    {
+        string255 substr1 = STRINIT("123");
+        string255 str1 = STRINIT("12345");
 
-		string255 substr2 = STRINIT("45");
-		string255 str2 = STRINIT("12345");
+        string255 substr2 = STRINIT("45");
+        string255 str2 = STRINIT("12345");
 
-		string255 substr3 = STRINIT("");
-		string255 str3 = STRINIT("12345");
+        string255 substr3 = STRINIT("");
+        string255 str3 = STRINIT("12345");
 
-		string255 substr4 = STRINIT("123");
-		string255 str4 = STRINIT("");
+        string255 substr4 = STRINIT("123");
+        string255 str4 = STRINIT("");
 
-		string255 substr5 = STRINIT("123");
-		string255 str5 = STRINIT("456");
+        string255 substr5 = STRINIT("123");
+        string255 str5 = STRINIT("456");
 
-		fail_unless(fpcrtl_posS(substr1, str1) == 1, "pos(123, 12345)");
-		fail_unless(fpcrtl_posS(substr2, str2) == 4, "pos(45, 12345)");
-		fail_unless(fpcrtl_posS(substr3, str3) == 0, "pos(, 12345)");
-		fail_unless(fpcrtl_posS(substr4, str4) == 0, "pos(123, )");
-		fail_unless(fpcrtl_posS(substr5, str5) == 0, "pos(123, 456)");
-	}
+        fail_unless(fpcrtl_posS(substr1, str1) == 1, "pos(123, 12345)");
+        fail_unless(fpcrtl_posS(substr2, str2) == 4, "pos(45, 12345)");
+        fail_unless(fpcrtl_posS(substr3, str3) == 0, "pos(, 12345)");
+        fail_unless(fpcrtl_posS(substr4, str4) == 0, "pos(123, )");
+        fail_unless(fpcrtl_posS(substr5, str5) == 0, "pos(123, 456)");
+    }
 END_TEST
 
 START_TEST (test_trunc)
-	{
-		  fail_unless(fpcrtl_trunc(123.456) == 123, "trunc(123.456)");
-		  fail_unless(fpcrtl_trunc(-123.456) == -123, "trunc(-123.456)");
-		  fail_unless(fpcrtl_trunc(12.3456) == 12, "trunc(12.3456)");
-		  fail_unless(fpcrtl_trunc(-12.3456) == -12, "trunc(-12.3456)");
-	}
+    {
+          fail_unless(fpcrtl_trunc(123.456) == 123, "trunc(123.456)");
+          fail_unless(fpcrtl_trunc(-123.456) == -123, "trunc(-123.456)");
+          fail_unless(fpcrtl_trunc(12.3456) == 12, "trunc(12.3456)");
+          fail_unless(fpcrtl_trunc(-12.3456) == -12, "trunc(-12.3456)");
+    }
 END_TEST
 
 START_TEST (test_odd)
 {
-	fail_unless(fpcrtl_odd(123) != 0, "odd(123)");
-	fail_unless(fpcrtl_odd(124) == 0, "odd(124)");
-	fail_unless(fpcrtl_odd(0) == 0, "odd(0)");
-	fail_unless(fpcrtl_odd(-1) != 0, "odd(-1)");
-	fail_unless(fpcrtl_odd(-2) == 0, "odd(-2)");
+    fail_unless(fpcrtl_odd(123) != 0, "odd(123)");
+    fail_unless(fpcrtl_odd(124) == 0, "odd(124)");
+    fail_unless(fpcrtl_odd(0) == 0, "odd(0)");
+    fail_unless(fpcrtl_odd(-1) != 0, "odd(-1)");
+    fail_unless(fpcrtl_odd(-2) == 0, "odd(-2)");
 }
 END_TEST
 
 START_TEST (test_sqr)
 {
-	fail_unless(fpcrtl_sqr(0) == 0, "sqr(0)");
-	fail_unless(fpcrtl_sqr(5) == 25, "sqr(5)");
-	fail_unless(fpcrtl_sqr(-5) == 25, "sqr(-5)");
+    fail_unless(fpcrtl_sqr(0) == 0, "sqr(0)");
+    fail_unless(fpcrtl_sqr(5) == 25, "sqr(5)");
+    fail_unless(fpcrtl_sqr(-5) == 25, "sqr(-5)");
 }
 END_TEST
 
 START_TEST (test_lowercase)
 {
-	string255 s1 = STRINIT("");
-	string255 s2 = STRINIT("a");
-	string255 s3 = STRINIT("abc");
-	string255 t;
+    string255 s1 = STRINIT("");
+    string255 s2 = STRINIT("a");
+    string255 s3 = STRINIT("abc");
+    string255 t;
 
-	t = fpcrtl_lowerCase(make_string(""));
-	fail_if(strcmp(t.str, s1.str), "lowerCase(\"\")");
+    t = fpcrtl_lowerCase(make_string(""));
+    fail_if(strcmp(t.str, s1.str), "lowerCase(\"\")");
 
-	t = fpcrtl_lowerCase(make_string("a"));
-	fail_if(strcmp(t.str, s2.str), "lowerCase(\"a\")");
+    t = fpcrtl_lowerCase(make_string("a"));
+    fail_if(strcmp(t.str, s2.str), "lowerCase(\"a\")");
 
-	t = fpcrtl_lowerCase(make_string("A"));
-	fail_if(strcmp(t.str, s2.str), "lowerCase(\"A\")");
+    t = fpcrtl_lowerCase(make_string("A"));
+    fail_if(strcmp(t.str, s2.str), "lowerCase(\"A\")");
 
-	t = fpcrtl_lowerCase(make_string("AbC"));
-	fail_if(strcmp(t.str, s3.str), "lowerCase(\"AbC\")");
+    t = fpcrtl_lowerCase(make_string("AbC"));
+    fail_if(strcmp(t.str, s3.str), "lowerCase(\"AbC\")");
 
-	t = fpcrtl_lowerCase(make_string("abc"));
-	fail_if(strcmp(t.str, s3.str), "lowerCase(\"abc\")");
+    t = fpcrtl_lowerCase(make_string("abc"));
+    fail_if(strcmp(t.str, s3.str), "lowerCase(\"abc\")");
 }
 END_TEST
 
 START_TEST (test_str)
 {
-	int8_t a1 = -8;
-	uint8_t a2 = 8;
-	int16_t a3 = -13;
-	uint16_t a4 = 13;
-	int32_t a5 = -19;
-	uint32_t a6 = 22;
-	int64_t a7 = -199999999999999;
-	uint64_t a8 = 200000000000000;
+    int8_t a1 = -8;
+    uint8_t a2 = 8;
+    int16_t a3 = -13;
+    uint16_t a4 = 13;
+    int32_t a5 = -19;
+    uint32_t a6 = 22;
+    int64_t a7 = -199999999999999;
+    uint64_t a8 = 200000000000000;
 
-	float a9 = 12345.6789;
-	double a10 = -9876.54321;
+    float a9 = 12345.6789;
+    double a10 = -9876.54321;
 
-	string255 s;
+    string255 s;
 
-	printf("-----Entering test str-----\n");
+    printf("-----Entering test str-----\n");
 
-	fpcrtl_str(a1, s);
-	printf("%d == %s\n", a1, s.str);
+    fpcrtl_str(a1, s);
+    printf("%d == %s\n", a1, s.str);
 
-	fpcrtl_str(a2, s);
-	printf("%u == %s\n", a2, s.str);
+    fpcrtl_str(a2, s);
+    printf("%u == %s\n", a2, s.str);
 
-	fpcrtl_str(a3, s);
-	printf("%d == %s\n", a3, s.str);
+    fpcrtl_str(a3, s);
+    printf("%d == %s\n", a3, s.str);
 
-	fpcrtl_str(a4, s);
-	printf("%u == %s\n", a4, s.str);
+    fpcrtl_str(a4, s);
+    printf("%u == %s\n", a4, s.str);
 
-	fpcrtl_str(a5, s);
-	printf("%d == %s\n", a5, s.str);
+    fpcrtl_str(a5, s);
+    printf("%d == %s\n", a5, s.str);
 
-	fpcrtl_str(a6, s);
-	printf("%u == %s\n", a6, s.str);
+    fpcrtl_str(a6, s);
+    printf("%u == %s\n", a6, s.str);
 
-	fpcrtl_str(a7, s);
-	printf("%lld == %s\n", a7, s.str);
+    fpcrtl_str(a7, s);
+    printf("%lld == %s\n", a7, s.str);
 
-	fpcrtl_str(a8, s);
-	printf("%llu == %s\n", a8, s.str);
+    fpcrtl_str(a8, s);
+    printf("%llu == %s\n", a8, s.str);
 
-	fpcrtl_str(a9, s);
-	printf("%f == %s\n", a9, s.str);
+    fpcrtl_str(a9, s);
+    printf("%f == %s\n", a9, s.str);
 
-	fpcrtl_str(a10, s);
-	printf("%f == %s\n", a10, s.str);
+    fpcrtl_str(a10, s);
+    printf("%f == %s\n", a10, s.str);
 
-	printf("-----Leaving test str------\n");
+    printf("-----Leaving test str------\n");
 }
 END_TEST
 
 Suite* system_suite(void)
 {
-	Suite *s = suite_create("system");
+    Suite *s = suite_create("system");
 
-	TCase *tc_core = tcase_create("Core");
+    TCase *tc_core = tcase_create("Core");
 
-	tcase_add_test(tc_core, test_copy);
-	tcase_add_test(tc_core, test_FloatToStr);
-	tcase_add_test(tc_core, test_random);
-	tcase_add_test(tc_core, test_posS);
-	tcase_add_test(tc_core, test_trunc);
-	tcase_add_test(tc_core, test_delete);
-	tcase_add_test(tc_core, test_odd);
-	tcase_add_test(tc_core, test_sqr);
-	tcase_add_test(tc_core, test_lowercase);
-	tcase_add_test(tc_core, test_str);
+    tcase_add_test(tc_core, test_copy);
+    tcase_add_test(tc_core, test_FloatToStr);
+    tcase_add_test(tc_core, test_random);
+    tcase_add_test(tc_core, test_posS);
+    tcase_add_test(tc_core, test_trunc);
+    tcase_add_test(tc_core, test_delete);
+    tcase_add_test(tc_core, test_odd);
+    tcase_add_test(tc_core, test_sqr);
+    tcase_add_test(tc_core, test_lowercase);
+    tcase_add_test(tc_core, test_str);
 
-	suite_add_tcase(s, tc_core);
+    suite_add_tcase(s, tc_core);
 
-	return s;
+    return s;
 }
 
--- a/project_files/hwc/rtl/tests/check_sysutils.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/check_sysutils.c	Tue Jan 21 22:38:13 2014 +0100
@@ -6,75 +6,75 @@
 
 static string255 make_string(const char* str)
 {
-	string255 s;
-	s.len = strlen(str);
-	memcpy(s.str, str, s.len + 1);
-	return s;
+    string255 s;
+    s.len = strlen(str);
+    memcpy(s.str, str, s.len + 1);
+    return s;
 }
 
 static int is_string_equal(string255 s1, string255 s2)
 {
-	return (s1.len == s2.len) && (strcmp(s1.str, s2.str) == 0);
+    return (s1.len == s2.len) && (strcmp(s1.str, s2.str) == 0);
 }
 
 START_TEST (test_trim)
 {
-	string255 t;
+    string255 t;
 
-	t = fpcrtl_trim(make_string(""));
-	fail_if(strcmp(t.str, ""), "trim(\"\")");
+    t = fpcrtl_trim(make_string(""));
+    fail_if(strcmp(t.str, ""), "trim(\"\")");
 
-	t = fpcrtl_trim(make_string("ab"));
-	fail_if(strcmp(t.str, "ab"), "trim(\"ab\")");
+    t = fpcrtl_trim(make_string("ab"));
+    fail_if(strcmp(t.str, "ab"), "trim(\"ab\")");
 
-	t = fpcrtl_trim(make_string(" "));
-	fail_if(strcmp(t.str, ""), "trim(\" \")");
+    t = fpcrtl_trim(make_string(" "));
+    fail_if(strcmp(t.str, ""), "trim(\" \")");
 
-	t = fpcrtl_trim(make_string("   "));
-	fail_if(strcmp(t.str, ""), "trim(\"   \")");
+    t = fpcrtl_trim(make_string("   "));
+    fail_if(strcmp(t.str, ""), "trim(\"   \")");
 
-	t = fpcrtl_trim(make_string(" ab"));
-	fail_if(strcmp(t.str, "ab"), "trim(\" ab\")");
+    t = fpcrtl_trim(make_string(" ab"));
+    fail_if(strcmp(t.str, "ab"), "trim(\" ab\")");
 
-	t = fpcrtl_trim(make_string("ab  "));
-	fail_if(strcmp(t.str, "ab"), "trim(\"ab  \")");
+    t = fpcrtl_trim(make_string("ab  "));
+    fail_if(strcmp(t.str, "ab"), "trim(\"ab  \")");
 
-	t = fpcrtl_trim(make_string("  ab  "));
-	fail_if(strcmp(t.str, "ab"), "trim(\"  ab  \")");
+    t = fpcrtl_trim(make_string("  ab  "));
+    fail_if(strcmp(t.str, "ab"), "trim(\"  ab  \")");
 
 }
 END_TEST
 
 START_TEST (test_strToInt)
 {
-	fail_unless(fpcrtl_strToInt(make_string("123")) == 123, "strToInt(\"123\")");
-	fail_unless(fpcrtl_strToInt(make_string("0")) == 0, "strToInt(\"0\")");
-	fail_unless(fpcrtl_strToInt(make_string("-123")) == -123, "strToInt(\"-123\")");
+    fail_unless(fpcrtl_strToInt(make_string("123")) == 123, "strToInt(\"123\")");
+    fail_unless(fpcrtl_strToInt(make_string("0")) == 0, "strToInt(\"0\")");
+    fail_unless(fpcrtl_strToInt(make_string("-123")) == -123, "strToInt(\"-123\")");
 }
 END_TEST
 
 START_TEST (test_extractFileName)
 {
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("abc")), make_string("abc")), "extractFileName(\"abc\")");
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("a:abc")), make_string("abc")), "extractFileName(\"a:abc\")");
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("/abc")), make_string("abc")), "extractFileName(\"/abc\")");
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("\\abc")), make_string("abc")), "extractFileName(\"\\abc\")");
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("/usr/bin/abc")), make_string("abc")), "extractFileName(\"/usr/bin/abc\")");
-	fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("c:\\def\\abc")), make_string("abc")), "extractFileName(\"c:\\def\\abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("abc")), make_string("abc")), "extractFileName(\"abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("a:abc")), make_string("abc")), "extractFileName(\"a:abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("/abc")), make_string("abc")), "extractFileName(\"/abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("\\abc")), make_string("abc")), "extractFileName(\"\\abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("/usr/bin/abc")), make_string("abc")), "extractFileName(\"/usr/bin/abc\")");
+    fail_unless(is_string_equal(fpcrtl_extractFileName(make_string("c:\\def\\abc")), make_string("abc")), "extractFileName(\"c:\\def\\abc\")");
 }
 END_TEST
 
 Suite* sysutils_suite(void)
 {
-	Suite *s = suite_create("sysutils");
+    Suite *s = suite_create("sysutils");
 
-	TCase *tc_core = tcase_create("Core");
+    TCase *tc_core = tcase_create("Core");
 
-	tcase_add_test(tc_core, test_trim);
-	tcase_add_test(tc_core, test_strToInt);
-	tcase_add_test(tc_core, test_extractFileName);
+    tcase_add_test(tc_core, test_trim);
+    tcase_add_test(tc_core, test_strToInt);
+    tcase_add_test(tc_core, test_extractFileName);
 
-	suite_add_tcase(s, tc_core);
+    suite_add_tcase(s, tc_core);
 
-	return s;
+    return s;
 }
--- a/project_files/hwc/rtl/tests/fileio_test.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/fileio_test.c	Tue Jan 21 22:38:13 2014 +0100
@@ -55,5 +55,5 @@
 
 int main(int argc, char** argv)
 {
-	readThemeCfg_0();
+    readThemeCfg_0();
 }
--- a/project_files/hwc/rtl/tests/main.c	Thu Jan 09 19:10:12 2014 +0100
+++ b/project_files/hwc/rtl/tests/main.c	Tue Jan 21 22:38:13 2014 +0100
@@ -1,84 +1,80 @@
-
-//#include <stdio.h>
-//#include "fpcrtl.h"
-//#include "fileio.h"
-//
-//string255 t = STRINIT("test");
-//string255 Pathz[1] = {STRINIT(".")};
-////int ptCurrTheme = 0;
-//string255 cThemeCFGFilename = STRINIT("theme.cfg");
-//const string255 __str79 = STRINIT("object");
-//string255 c1 = STRINIT("=");
-//string255 c2 = STRINIT("\x2c");
-//string255 c3 = STRINIT("\x2f");
-//
-//typedef struct __TResourceList {
-//            Integer count;
-//            string255 files[500 + 1];
-//} TResourceList;
-//
-//TResourceList readThemeCfg_0()
-//{
-//    TResourceList readthemecfg_result;
-//    string255 s;
-//    string255 key;
-//    TextFile f;
-//    Integer i;
-//    TResourceList result;
-//
-//    int t = 0;
-//
-//    s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
-//
-//    assign(&f, s);
-//
-//    reset(&f);
-//
-//    if(f.fp == NULL){
-//    	readthemecfg_result.count = 0;
-//    	return readthemecfg_result;
-//    }
-//
-//    result.count = 0;
-//    while(!eof(&f))
-//    {
-//        readLnS(&f, &s);
-//
-//        if((Length(s)) == (0))
-//        {
-//            continue;
-//        }
-//        if((s.s[1]) == ('\x3b'))
-//        {
-//            continue;
-//        }
-//
-//        i = pos(c1, s);
-//
-//        key = fpcrtl_trim(fpcrtl_copy(s, 1, i - 1));
-//
-//        fpcrtl_delete(&s, 1, i);
-//
-//        if(_strcompare(key, __str79))
-//        {
-//            i = pos(c2, s);
-//            result.files[result.count] = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), trim(copy(s, 1, i - 1)));
-//            ++result.count;
-//        }
-//    }
-//
-//    close(&f);
-//    readthemecfg_result = result;
-//    return readthemecfg_result;
-//}
-//
-int main(int argc, char** argv)
-{
-	int i;
-
-//	TResourceList result = readThemeCfg_0();
-//	for(i = 0; i < result.count; i++){
-//		printf("%s\n", result.files[i].str);
-//	}
-
-}
+#if 0
+#include <stdio.h>
+#include "fpcrtl.h"
+#include "fileio.h"
+
+string255 t = STRINIT("test");
+string255 Pathz[1] = {STRINIT(".")};
+//int ptCurrTheme = 0;
+string255 cThemeCFGFilename = STRINIT("theme.cfg");
+const string255 __str79 = STRINIT("object");
+string255 c1 = STRINIT("=");
+string255 c2 = STRINIT("\x2c");
+string255 c3 = STRINIT("\x2f");
+
+typedef struct __TResourceList {
+            Integer count;
+            string255 files[500 + 1];
+} TResourceList;
+
+TResourceList readThemeCfg_0()
+{
+    TResourceList readthemecfg_result;
+    string255 s;
+    string255 key;
+    TextFile f;
+    Integer i;
+    TResourceList result;
+
+    int t = 0;
+
+    s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
+
+    assign(&f, s);
+
+    reset(&f);
+
+    if (f.fp == NULL) {
+      readthemecfg_result.count = 0;
+      return readthemecfg_result;
+    }
+
+    result.count = 0;
+    while (!eof(&f)) {
+        readLnS(&f, &s);
+
+        if ((Length(s)) == (0)) {
+            continue;
+        }
+        if ((s.s[1]) == ('\x3b')) {
+            continue;
+        }
+
+        i = pos(c1, s);
+
+        key = fpcrtl_trim(fpcrtl_copy(s, 1, i - 1));
+
+        fpcrtl_delete(&s, 1, i);
+
+        if (_strcompare(key, __str79)) {
+            i = pos(c2, s);
+            result.files[result.count] = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), trim(copy(s, 1, i - 1)));
+            ++result.count;
+        }
+    }
+
+    close(&f);
+    readthemecfg_result = result;
+    return readthemecfg_result;
+}
+
+int main(int argc, char** argv)
+{
+    int i;
+
+    TResourceList result = readThemeCfg_0();
+    for(i = 0; i < result.count; i++) {
+        printf("%s\n", result.files[i].str);
+    }
+}
+#endif
--- a/share/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -8,7 +8,7 @@
     #CFBundleShortVersionString is HEDGEWARS_VERSION
 
     #libav/ffmpeg always brings in VideoDecoderAcceleration, avaible only from 10.6.3
-    if(${FFMPEG_FOUND} AND ${minimum_macosx_version} VERSION_EQUAL "10.6")
+    if(LIBAV_FOUND AND ${minimum_macosx_version} VERSION_EQUAL "10.6")
         set(minimum_macosx_version "10.6.3")
     endif()
 
--- a/share/hedgewars/Data/Fonts/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/hedgewars/Data/Fonts/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -1,4 +1,26 @@
-install(FILES
+set(FONTFILES
     DejaVuSans-Bold.ttf
-    wqy-zenhei.ttc
-    DESTINATION ${SHAREPATH}Data/Fonts)
+    wqy-zenhei.ttc)
+
+if (FONTS_DIRS)
+    foreach(fontfile ${FONTFILES})
+        set(missing 1)
+        foreach(fontdir ${FONTS_DIRS})
+            if (EXISTS "${fontdir}/${fontfile}")
+                message(STATUS "Fonts: Found ${fontfile} in ${fontdir}")
+                set(missing 0)
+                break()
+            endif()
+        endforeach(fontdir)
+        if(missing)
+            set(MISSINGFONTFILES ${MISSINGFONTFILES} ${fontfile})
+            message(STATUS "Fonts: Could not find ${fontfile}, it will be installed")
+        endif()
+    endforeach(fontfile)
+else()
+    set(MISSINGFONTFILES ${FONTFILES})
+endif()
+
+if (MISSINGFONTFILES)
+    install(FILES ${MISSINGFONTFILES} DESTINATION ${SHAREPATH}Data/Fonts)
+endif()
--- a/share/hedgewars/Data/Locale/hedgewars_de.ts	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/hedgewars/Data/Locale/hedgewars_de.ts	Tue Jan 21 22:38:13 2014 +0100
@@ -354,7 +354,7 @@
 Password:</source>
         <translation>Dieser Spitzname ist registriert und du hast kein Passwort angegeben.
 
-Falls dieser Spitzname nicht deiner ist, dann registirier bitte deinen eigenen Spitznamen an www.hedgewars.org.
+Falls dieser Spitzname nicht deiner ist, dann registriere bitte deinen eigenen Spitznamen an www.hedgewars.org.
 
 Passwort:</translation>
     </message>
--- a/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Tue Jan 21 22:38:13 2014 +0100
@@ -11,12 +11,21 @@
 local wdTTL = 0
 local mln = 1000000
 
-function onNewTurn()
+local script2_onNewTurn
+local script2_onGameTick20
+local script2_onGameStart
+
+
+function grav_onNewTurn()
     SetGravity(gravity)
     wdGameTicks = GameTime
+    
+    if script2_onNewTurn ~= nil then
+        script2_onNewTurn()
+    end    
 end
 
-function onGameTick20()
+function grav_onGameTick20()
     if wdGameTicks + 15000 < GameTime then
         SetGravity(100)
     else
@@ -49,9 +58,13 @@
     end
 
     wdTTL = TurnTimeLeft
+    
+    if script2_onGameTick20 ~= nil then
+        script2_onGameTick20()
+    end    
 end
 
-function onGameInit()
+function onParameters()
     parseParams()
 
     gravity = params["g"]
@@ -86,9 +99,28 @@
     if gravity == nil then
         gravity = 100
     end
+    
+    secondScript = params["script2"]
+    
+    if secondScript ~= nil then
+        onParameters = nil
+        HedgewarsScriptLoad("/Scripts/Multiplayer/" .. secondScript .. ".lua")
+        
+        script2_onNewTurn = onNewTurn
+        script2_onGameTick20 = onGameTick20
+        script2_onGameStart = onGameStart
+                
+        if onParameters ~= nil then
+            onParameters()
+        end
+    end
+    
+    onNewTurn = grav_onNewTurn
+    onGameTick20 = grav_onGameTick20
+    onGameStart = grav_onGameStart
 end
 
-function onGameStart()
+function grav_onGameStart()
     if delta == nil then
         v = string.format(loc("random in range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40)
     elseif period ~= nil then
@@ -103,4 +135,10 @@
                 .. loc("or 'g=50, g2=150, period=4000' for gravity changing|from 50 to 150 and back with period of 4000 msec")
                 .. "||" .. loc("Set period to negative value for random gravity"),
                 0, 5000)
+                
+    if script2_onGameStart ~= nil then
+        script2_onGameStart()
+    end
 end
+
+
--- a/share/hedgewars/Data/Scripts/Params.lua	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Params.lua	Tue Jan 21 22:38:13 2014 +0100
@@ -3,7 +3,9 @@
 params = {}
 
 function parseParams()
-    for k, v in string.gmatch(ScriptParam, "(%w+)=([^,]+)") do
-        params[k] = v
+    if ScriptParam ~= nil then
+        for k, v in string.gmatch(ScriptParam, "(%w+)=([^,]+)") do
+            params[k] = v
+        end
     end
 end
--- a/share/hedgewars/Data/Shaders/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/share/hedgewars/Data/Shaders/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -2,6 +2,6 @@
 file(GLOB fragshaders *.fs)
 
 install(FILES
-	${vertshaders}
-	${fragshaders}
-	DESTINATION ${SHAREPATH}Data/Shaders)
+    ${vertshaders}
+    ${fragshaders}
+    DESTINATION ${SHAREPATH}Data/Shaders)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lua/luaAPI/zoom_get_set.lua	Tue Jan 21 22:38:13 2014 +0100
@@ -0,0 +1,68 @@
+
+-- This function is called before the game loads its
+-- resources.
+-- It's one of the predefined function names that will
+-- be called by the game. They give you entry points
+-- where you're able to call your own code using either
+-- provided instructions or custom functions.
+function onGameInit()
+	-- At first we have to overwrite/set some global variables
+	-- that define the map, the game has to load, as well as
+	-- other things such as the game rules to use, etc.
+	-- Things we don't modify here will use their default values.
+
+	-- The base number for the random number generator
+	Seed = 1
+	-- The map to be played
+	Map = "Bamboo"
+	-- The theme to be used
+	Theme = "Bamboo"
+	-- Game settings and rules
+	EnableGameFlags(gfOneClanMode)
+
+	-- Create the player team
+	AddTeam("'Zooka Team", 14483456, "Simple", "Island", "Default")
+	-- And add a hog to it
+	player = AddHog("Hunter", 0, 1, "NoHat")
+	SetGearPosition(player, 936, 136)
+end
+
+-- from lua API wiki:
+local minZoom = 1.0;
+local maxZoom = 3.0;
+local defaultZoom = 2.0;
+
+local nFails = 0;
+
+function TestZoom(value)
+	exp = math.max(minZoom, math.min(maxZoom, value))
+	SetZoom(value)
+	z = GetZoom()
+	-- compare with some tolerance - because of float inprecision
+	if (z > exp + 0.01) or (z < exp - 0.01) then
+		WriteLnToConsole("Expected zoom value " .. exp .. " (after setting go zoom to " .. value .. "), but got: " .. z )
+		nFails = nFails + 1
+	end
+end
+
+function onGameStart()
+	if (GetZoom() ~= defaultZoom) then
+		WriteLnToConsole("Game did not start with zoom level of " .. defaultZoom)
+		nFails = 1
+	end
+
+	TestZoom(0)
+	TestZoom(1)
+	TestZoom(0.5)
+	TestZoom(3.5)
+	TestZoom(7)
+	TestZoom(2.0)
+	TestZoom(2.2)
+
+	if (nFails > 0) then
+		EndLuaTest(TEST_FAILED)
+	else
+		EndLuaTest(TEST_SUCCESSFUL)
+	end
+end
+
--- a/tools/CMakeLists.txt	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/CMakeLists.txt	Tue Jan 21 22:38:13 2014 +0100
@@ -1,4 +1,4 @@
-if (NOT APPLE)
+if(NOT APPLE)
     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
                    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
                     IMMEDIATE @ONLY)
@@ -6,7 +6,7 @@
     add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
 endif()
 
-if (APPLE)
+if(APPLE)
     find_package(Qt4 REQUIRED QUIET)
     find_package(SDL REQUIRED)
     find_package(SDL_image REQUIRED)
@@ -17,7 +17,7 @@
     if(NOT NOAUTOUPDATE)
         find_package(Sparkle) #needed for SPARKLE_FOUND variable
         #needed because the 'if' clause in the script prints silly policy warnings
-        if(${SPARKLE_FOUND})
+        if(SPARKLE_FOUND)
             set(SPARKLE_FOUND 1)
         else()
             set(SPARKLE_FOUND 0)
--- a/tools/pas2c/Main.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/pas2c/Main.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -36,7 +36,7 @@
                       | otherwise ->  error $ usageInfo header options
           (_,     nonOpts, [])     -> error $ "unrecognized arguments: " ++ unwords nonOpts
           (_,     _,       msgs)   -> error $ usageInfo header options
-    where 
+    where
         header = "Freepascal to C conversion! Please specify -n -i -o options.\n"
         enoughFlags f = and $ map (isJust . flip find f) [isName, isInput, isOutput]
         flag f = extractString . fromJust . flip find f
--- a/tools/pas2c/Pas2C.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/pas2c/Pas2C.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -205,8 +205,8 @@
 renderEnum2Strs enums implement =
     render $ foldl ($+$) empty $ map (\en -> let d = decl (fst en) in if implement then d $+$ enum2strBlock (snd en) else d <> semi) enums
     where
-    decl id = text "string255 __attribute__((overloadable)) fpcrtl_GetEnumName" <> parens (text "int dummy, const" <+> text id <+> text "enumvar") 
-    enum2strBlock en = 
+    decl id = text "string255 __attribute__((overloadable)) fpcrtl_GetEnumName" <> parens (text "int dummy, const" <+> text id <+> text "enumvar")
+    enum2strBlock en =
             text "{"
             $+$
             (nest 4 $
@@ -382,7 +382,7 @@
         resolveTypeHelper' st b = do
             bt <- st
             return (b, bt)
-	
+
 resolveType :: TypeDecl -> State RenderState BaseType
 resolveType st@(SimpleType (Identifier i _)) = do
     let i' = map toLower i
@@ -410,8 +410,8 @@
     return $ BTArray i (BTInt True) t'
 resolveType (ArrayDecl Nothing t) = liftM (BTArray RangeInfinite (BTInt True)) $ resolveType t
 resolveType (FunctionType t a) = do
-	bts <- typeVarDecl2BaseType a
-	liftM (BTFunction False bts) $ resolveType t
+    bts <- typeVarDecl2BaseType a
+    liftM (BTFunction False bts) $ resolveType t
 resolveType (DeriveType (InitHexNumber _)) = return (BTInt True)
 resolveType (DeriveType (InitNumber _)) = return (BTInt True)
 resolveType (DeriveType (InitFloat _)) = return BTFloat
@@ -645,8 +645,8 @@
     e2 <- initExpr2C' expr2
     return $ parens $ e1 <+> text (op2C op) <+> e2
 initExpr2C' (InitNumber s) = do
-								modify(\s -> s{lastType = (BTInt True)})
-								return $ text s
+                                modify(\s -> s{lastType = (BTInt True)})
+                                return $ text s
 initExpr2C' (InitFloat s) = return $ text s
 initExpr2C' (InitHexNumber s) = return $ text "0x" <> (text . map toLower $ s)
 initExpr2C' (InitString [a]) = return . quotes $ text [a]
@@ -872,7 +872,7 @@
         i <+> text "=" <+> e1 <> semi
         $$
         iType <+> iEnd <+> text "=" <+> e2 <> semi
-        $$ 
+        $$
         text "if" <+> (parens $ i <+> text (if up then "<=" else ">=") <+> iEnd) <+> text "do" <+> ph <+>
         text "while" <> parens (i <+> text "!=" <+> iEnd <+> text add) <> semi
     where
@@ -1062,7 +1062,7 @@
     case t of
          BTFunction _ _ rt -> do
              modify(\s -> s{lastType = rt})
-             return $ if addParens then i <> parens empty else i 
+             return $ if addParens then i <> parens empty else i
          _ -> return $ i
 ref2CF r _ = ref2C r
 
@@ -1121,9 +1121,9 @@
     t <- gets lastType
     case t of
         BTFunction _ bts t' -> do
-            ps <- liftM (parens . hsep . punctuate (char ',')) $ 
+            ps <- liftM (parens . hsep . punctuate (char ',')) $
                     if (length params) == (length bts) -- hot fix for pas2cSystem and pas2cRedo functions since they don't have params
-                    then 
+                    then
                         mapM expr2CHelper (zip params bts)
                     else mapM expr2C params
             modify (\s -> s{lastType = t'})
--- a/tools/pas2c/PascalBasics.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/pas2c/PascalBasics.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -1,70 +1,70 @@
-{-# LANGUAGE FlexibleContexts #-}
-module PascalBasics where
-
-import Text.Parsec.Combinator
-import Text.Parsec.Char
-import Text.Parsec.Prim
-import Text.Parsec.Token
-import Text.Parsec.Language
-import Data.Char
-
-builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit", "break", "continue", "length"]
-
-pascalLanguageDef
-    = emptyDef
-    { commentStart   = "(*"
-    , commentEnd     = "*)"
-    , commentLine    = "//"
-    , nestedComments = False
-    , identStart     = letter <|> oneOf "_"
-    , identLetter    = alphaNum <|> oneOf "_"
-    , opLetter       = letter
-    , reservedNames  = [
-            "begin", "end", "program", "unit", "interface"
-            , "implementation", "and", "or", "xor", "shl"
-            , "shr", "while", "do", "repeat", "until", "case", "of"
-            , "type", "var", "const", "out", "array", "packed"
-            , "procedure", "function", "with", "for", "to"
-            , "downto", "div", "mod", "record", "set", "nil"
-            , "cdecl", "external", "if", "then", "else"
-            ] -- ++ builtin
-    , caseSensitive  = False
-    }
-
-preprocessorSwitch :: Stream s m Char => ParsecT s u m String
-preprocessorSwitch = do
-    try $ string "{$"
-    s <- manyTill (noneOf "\n") $ char '}'
-    return s
-
-caseInsensitiveString s = do
-    mapM_ (\a -> satisfy (\b -> toUpper a == toUpper b)) s <?> s
-    return s
-
-pas = patch $ makeTokenParser pascalLanguageDef
-    where
-    patch tp = tp {stringLiteral = stringL}
-
-comment = choice [
-        char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}')
-        , (try $ string "(*") >> manyTill anyChar (try $ string "*)")
-        , (try $ string "//") >> manyTill anyChar (try newline)
-        ]
-
-comments = do
-    spaces
-    skipMany $ do
-        preprocessorSwitch <|> comment
-        spaces
-
-stringL = do
-    (char '\'')
-    s <- (many $ noneOf "'")
-    (char '\'')
-    ss <- many $ do
-        (char '\'')
-        s' <- (many $ noneOf "'")
-        (char '\'')
-        return $ '\'' : s'
-    comments
-    return $ concat (s:ss)
+{-# LANGUAGE FlexibleContexts #-}
+module PascalBasics where
+
+import Text.Parsec.Combinator
+import Text.Parsec.Char
+import Text.Parsec.Prim
+import Text.Parsec.Token
+import Text.Parsec.Language
+import Data.Char
+
+builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit", "break", "continue", "length"]
+
+pascalLanguageDef
+    = emptyDef
+    { commentStart   = "(*"
+    , commentEnd     = "*)"
+    , commentLine    = "//"
+    , nestedComments = False
+    , identStart     = letter <|> oneOf "_"
+    , identLetter    = alphaNum <|> oneOf "_"
+    , opLetter       = letter
+    , reservedNames  = [
+            "begin", "end", "program", "unit", "interface"
+            , "implementation", "and", "or", "xor", "shl"
+            , "shr", "while", "do", "repeat", "until", "case", "of"
+            , "type", "var", "const", "out", "array", "packed"
+            , "procedure", "function", "with", "for", "to"
+            , "downto", "div", "mod", "record", "set", "nil"
+            , "cdecl", "external", "if", "then", "else"
+            ] -- ++ builtin
+    , caseSensitive  = False
+    }
+
+preprocessorSwitch :: Stream s m Char => ParsecT s u m String
+preprocessorSwitch = do
+    try $ string "{$"
+    s <- manyTill (noneOf "\n") $ char '}'
+    return s
+
+caseInsensitiveString s = do
+    mapM_ (\a -> satisfy (\b -> toUpper a == toUpper b)) s <?> s
+    return s
+
+pas = patch $ makeTokenParser pascalLanguageDef
+    where
+    patch tp = tp {stringLiteral = stringL}
+
+comment = choice [
+        char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}')
+        , (try $ string "(*") >> manyTill anyChar (try $ string "*)")
+        , (try $ string "//") >> manyTill anyChar (try newline)
+        ]
+
+comments = do
+    spaces
+    skipMany $ do
+        preprocessorSwitch <|> comment
+        spaces
+
+stringL = do
+    (char '\'')
+    s <- (many $ noneOf "'")
+    (char '\'')
+    ss <- many $ do
+        (char '\'')
+        s' <- (many $ noneOf "'")
+        (char '\'')
+        return $ '\'' : s'
+    comments
+    return $ concat (s:ss)
--- a/tools/pas2c/PascalPreprocessor.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/pas2c/PascalPreprocessor.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -1,130 +1,130 @@
-{-# LANGUAGE ScopedTypeVariables #-}
-module PascalPreprocessor where
-
-import Text.Parsec
-import Control.Monad.IO.Class
-import Control.Monad
-import System.IO
-import qualified Data.Map as Map
-import Control.Exception(catch, IOException)
-import Data.Char
-import Prelude hiding (catch)
-
--- comments are removed
-comment = choice [
-        char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}') >> return ""
-        , (try $ string "(*") >> manyTill anyChar (try $ string "*)") >> return ""
-        , (try $ string "//") >> manyTill anyChar (try newline) >> return "\n"
-        ]
-
-preprocess :: String -> String -> String -> [String] -> IO String
-preprocess inputPath alternateInputPath fn symbols = do
-    r <- runParserT (preprocessFile (inputPath ++ fn)) (Map.fromList $ map (\s -> (s, "")) symbols, [True]) "" ""
-    case r of
-         (Left a) -> do
-             hPutStrLn stderr (show a)
-             return ""
-         (Right a) -> return a
-
-    where
-    preprocessFile fn = do
-        f <- liftIO (readFile fn)
-        setInput f
-        preprocessor
-
-    preprocessor, codeBlock, switch :: ParsecT String (Map.Map String String, [Bool]) IO String
-
-    preprocessor = chainr codeBlock (return (++)) ""
-
-    codeBlock = do
-        s <- choice [
-            switch
-            , comment
-            , char '\'' >> many (noneOf "'\n") >>= \s -> char '\'' >> return ('\'' : s ++ "'")
-            , identifier >>= replace
-            , noneOf "{" >>= \a -> return [a]
-            ]
-        (_, ok) <- getState
-        return $ if and ok then s else ""
-
-    --otherChar c = c `notElem` "{/('_" && not (isAlphaNum c)
-    identifier = do
-        c <- letter <|> oneOf "_"
-        s <- many (alphaNum <|> oneOf "_")
-        return $ c:s
-
-    switch = do
-        try $ string "{$"
-        s <- choice [
-            include
-            , ifdef
-            , if'
-            , elseSwitch
-            , endIf
-            , define
-            , unknown
-            ]
-        return s
-
-    include = do
-        try $ string "INCLUDE"
-        spaces
-        (char '"')
-        fn <- many1 $ noneOf "\"\n"
-        char '"'
-        spaces
-        char '}'
-        f <- liftIO (readFile (inputPath ++ fn) `catch` (\(exc :: IOException) -> readFile (alternateInputPath ++ fn) `catch` (\(_ :: IOException) -> error ("File not found: " ++ fn))))
-        c <- getInput
-        setInput $ f ++ c
-        return ""
-
-    ifdef = do
-        s <- try (string "IFDEF") <|> try (string "IFNDEF")
-        let f = if s == "IFNDEF" then not else id
-
-        spaces
-        d <- identifier
-        spaces
-        char '}'
-
-        updateState $ \(m, b) ->
-            (m, (f $ d `Map.member` m) : b)
-
-        return ""
-
-    if' = do
-        s <- try (string "IF" >> notFollowedBy alphaNum)
-
-        manyTill anyChar (char '}')
-        --char '}'
-
-        updateState $ \(m, b) ->
-            (m, False : b)
-
-        return ""
-
-    elseSwitch = do
-        try $ string "ELSE}"
-        updateState $ \(m, b:bs) -> (m, (not b):bs)
-        return ""
-    endIf = do
-        try $ string "ENDIF}"
-        updateState $ \(m, b:bs) -> (m, bs)
-        return ""
-    define = do
-        try $ string "DEFINE"
-        spaces
-        i <- identifier
-        d <- ((string ":=" >> return ()) <|> spaces) >> many (noneOf "}")
-        char '}'
-        updateState $ \(m, b) -> (if (and b) && (head i /= '_') then Map.insert i d m else m, b)
-        return ""
-    replace s = do
-        (m, _) <- getState
-        return $ Map.findWithDefault s s m
-
-    unknown = do
-        fn <- many1 $ noneOf "}\n"
-        char '}'
-        return $ "{$" ++ fn ++ "}"
+{-# LANGUAGE ScopedTypeVariables #-}
+module PascalPreprocessor where
+
+import Text.Parsec
+import Control.Monad.IO.Class
+import Control.Monad
+import System.IO
+import qualified Data.Map as Map
+import Control.Exception(catch, IOException)
+import Data.Char
+import Prelude hiding (catch)
+
+-- comments are removed
+comment = choice [
+        char '{' >> notFollowedBy (char '$') >> manyTill anyChar (try $ char '}') >> return ""
+        , (try $ string "(*") >> manyTill anyChar (try $ string "*)") >> return ""
+        , (try $ string "//") >> manyTill anyChar (try newline) >> return "\n"
+        ]
+
+preprocess :: String -> String -> String -> [String] -> IO String
+preprocess inputPath alternateInputPath fn symbols = do
+    r <- runParserT (preprocessFile (inputPath ++ fn)) (Map.fromList $ map (\s -> (s, "")) symbols, [True]) "" ""
+    case r of
+         (Left a) -> do
+             hPutStrLn stderr (show a)
+             return ""
+         (Right a) -> return a
+
+    where
+    preprocessFile fn = do
+        f <- liftIO (readFile fn)
+        setInput f
+        preprocessor
+
+    preprocessor, codeBlock, switch :: ParsecT String (Map.Map String String, [Bool]) IO String
+
+    preprocessor = chainr codeBlock (return (++)) ""
+
+    codeBlock = do
+        s <- choice [
+            switch
+            , comment
+            , char '\'' >> many (noneOf "'\n") >>= \s -> char '\'' >> return ('\'' : s ++ "'")
+            , identifier >>= replace
+            , noneOf "{" >>= \a -> return [a]
+            ]
+        (_, ok) <- getState
+        return $ if and ok then s else ""
+
+    --otherChar c = c `notElem` "{/('_" && not (isAlphaNum c)
+    identifier = do
+        c <- letter <|> oneOf "_"
+        s <- many (alphaNum <|> oneOf "_")
+        return $ c:s
+
+    switch = do
+        try $ string "{$"
+        s <- choice [
+            include
+            , ifdef
+            , if'
+            , elseSwitch
+            , endIf
+            , define
+            , unknown
+            ]
+        return s
+
+    include = do
+        try $ string "INCLUDE"
+        spaces
+        (char '"')
+        fn <- many1 $ noneOf "\"\n"
+        char '"'
+        spaces
+        char '}'
+        f <- liftIO (readFile (inputPath ++ fn) `catch` (\(exc :: IOException) -> readFile (alternateInputPath ++ fn) `catch` (\(_ :: IOException) -> error ("File not found: " ++ fn))))
+        c <- getInput
+        setInput $ f ++ c
+        return ""
+
+    ifdef = do
+        s <- try (string "IFDEF") <|> try (string "IFNDEF")
+        let f = if s == "IFNDEF" then not else id
+
+        spaces
+        d <- identifier
+        spaces
+        char '}'
+
+        updateState $ \(m, b) ->
+            (m, (f $ d `Map.member` m) : b)
+
+        return ""
+
+    if' = do
+        s <- try (string "IF" >> notFollowedBy alphaNum)
+
+        manyTill anyChar (char '}')
+        --char '}'
+
+        updateState $ \(m, b) ->
+            (m, False : b)
+
+        return ""
+
+    elseSwitch = do
+        try $ string "ELSE}"
+        updateState $ \(m, b:bs) -> (m, (not b):bs)
+        return ""
+    endIf = do
+        try $ string "ENDIF}"
+        updateState $ \(m, b:bs) -> (m, bs)
+        return ""
+    define = do
+        try $ string "DEFINE"
+        spaces
+        i <- identifier
+        d <- ((string ":=" >> return ()) <|> spaces) >> many (noneOf "}")
+        char '}'
+        updateState $ \(m, b) -> (if (and b) && (head i /= '_') then Map.insert i d m else m, b)
+        return ""
+    replace s = do
+        (m, _) <- getState
+        return $ Map.findWithDefault s s m
+
+    unknown = do
+        fn <- many1 $ noneOf "}\n"
+        char '}'
+        return $ "{$" ++ fn ++ "}"
--- a/tools/pas2c/PascalUnitSyntaxTree.hs	Thu Jan 09 19:10:12 2014 +0100
+++ b/tools/pas2c/PascalUnitSyntaxTree.hs	Tue Jan 21 22:38:13 2014 +0100
@@ -1,119 +1,119 @@
-module PascalUnitSyntaxTree where
-
-import Data.Maybe
-import Data.Char
-
-data PascalUnit =
-    Program Identifier Implementation Phrase
-    | Unit Identifier Interface Implementation (Maybe Initialize) (Maybe Finalize)
-    | System [TypeVarDeclaration]
-    | Redo [TypeVarDeclaration]
-    deriving Show
-data Interface = Interface Uses TypesAndVars
-    deriving Show
-data Implementation = Implementation Uses TypesAndVars
-    deriving Show
-data Identifier = Identifier String BaseType
-    deriving Show
-data TypesAndVars = TypesAndVars [TypeVarDeclaration]
-    deriving Show
-data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl
-    | VarDeclaration Bool Bool ([Identifier], TypeDecl) (Maybe InitExpression)
-    | FunctionDeclaration Identifier Bool Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
-    | OperatorDeclaration String Identifier Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
-    deriving Show
-data TypeDecl = SimpleType Identifier
-    | RangeType Range
-    | Sequence [Identifier]
-    | ArrayDecl (Maybe Range) TypeDecl
-    | RecordType [TypeVarDeclaration] (Maybe [[TypeVarDeclaration]])
-    | PointerTo TypeDecl
-    | String Integer
-    | Set TypeDecl
-    | FunctionType TypeDecl [TypeVarDeclaration]
-    | DeriveType InitExpression
-    | VoidType
-    | VarParamType TypeDecl -- this is a hack
-    deriving Show
-data Range = Range Identifier
-           | RangeFromTo InitExpression InitExpression
-           | RangeInfinite
-    deriving Show
-data Initialize = Initialize String
-    deriving Show
-data Finalize = Finalize String
-    deriving Show
-data Uses = Uses [Identifier]
-    deriving Show
-data Phrase = ProcCall Reference [Expression]
-        | IfThenElse Expression Phrase (Maybe Phrase)
-        | WhileCycle Expression Phrase
-        | RepeatCycle Expression [Phrase]
-        | ForCycle Identifier Expression Expression Phrase Bool -- The last Boolean indicates wether it's up or down counting
-        | WithBlock Reference Phrase
-        | Phrases [Phrase]
-        | SwitchCase Expression [([InitExpression], Phrase)] (Maybe [Phrase])
-        | Assignment Reference Expression
-        | BuiltInFunctionCall [Expression] Reference
-        | NOP
-    deriving Show
-data Expression = Expression String
-    | BuiltInFunCall [Expression] Reference
-    | PrefixOp String Expression
-    | PostfixOp String Expression
-    | BinOp String Expression Expression
-    | StringLiteral String
-    | PCharLiteral String
-    | CharCode String
-    | HexCharCode String
-    | NumberLiteral String
-    | FloatLiteral String
-    | HexNumber String
-    | Reference Reference
-    | SetExpression [Identifier]
-    | Null
-    deriving Show
-data Reference = ArrayElement [Expression] Reference
-    | FunCall [Expression] Reference
-    | TypeCast Identifier Expression
-    | SimpleReference Identifier
-    | Dereference Reference
-    | RecordField Reference Reference
-    | Address Reference
-    | RefExpression Expression
-    deriving Show
-data InitExpression = InitBinOp String InitExpression InitExpression
-    | InitPrefixOp String InitExpression
-    | InitReference Identifier
-    | InitArray [InitExpression]
-    | InitRecord [(Identifier, InitExpression)]
-    | InitFloat String
-    | InitNumber String
-    | InitHexNumber String
-    | InitString String
-    | InitChar String
-    | BuiltInFunction String [InitExpression]
-    | InitSet [InitExpression]
-    | InitAddress InitExpression
-    | InitNull
-    | InitRange Range
-    | InitTypeCast Identifier InitExpression
-    deriving Show
-
-data BaseType = BTUnknown
-    | BTChar
-    | BTString
-    | BTInt Bool -- second param indicates whether signed or not
-    | BTBool
-    | BTFloat
-    | BTRecord String [(String, BaseType)]
-    | BTArray Range BaseType BaseType
-    | BTFunction Bool [(Bool, BaseType)] BaseType -- (Bool, BaseType), Bool indiciates whether var or not
-    | BTPointerTo BaseType
-    | BTUnresolved String
-    | BTSet BaseType
-    | BTEnum [String]
-    | BTVoid
-    | BTUnit
-    | BTVarParam BaseType
-    deriving Show
+module PascalUnitSyntaxTree where
+
+import Data.Maybe
+import Data.Char
+
+data PascalUnit =
+    Program Identifier Implementation Phrase
+    | Unit Identifier Interface Implementation (Maybe Initialize) (Maybe Finalize)
+    | System [TypeVarDeclaration]
+    | Redo [TypeVarDeclaration]
+    deriving Show
+data Interface = Interface Uses TypesAndVars
+    deriving Show
+data Implementation = Implementation Uses TypesAndVars
+    deriving Show
+data Identifier = Identifier String BaseType
+    deriving Show
+data TypesAndVars = TypesAndVars [TypeVarDeclaration]
+    deriving Show
+data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl
+    | VarDeclaration Bool Bool ([Identifier], TypeDecl) (Maybe InitExpression)
+    | FunctionDeclaration Identifier Bool Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
+    | OperatorDeclaration String Identifier Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
+    deriving Show
+data TypeDecl = SimpleType Identifier
+    | RangeType Range
+    | Sequence [Identifier]
+    | ArrayDecl (Maybe Range) TypeDecl
+    | RecordType [TypeVarDeclaration] (Maybe [[TypeVarDeclaration]])
+    | PointerTo TypeDecl
+    | String Integer
+    | Set TypeDecl
+    | FunctionType TypeDecl [TypeVarDeclaration]
+    | DeriveType InitExpression
+    | VoidType
+    | VarParamType TypeDecl -- this is a hack
+    deriving Show
+data Range = Range Identifier
+           | RangeFromTo InitExpression InitExpression
+           | RangeInfinite
+    deriving Show
+data Initialize = Initialize String
+    deriving Show
+data Finalize = Finalize String
+    deriving Show
+data Uses = Uses [Identifier]
+    deriving Show
+data Phrase = ProcCall Reference [Expression]
+        | IfThenElse Expression Phrase (Maybe Phrase)
+        | WhileCycle Expression Phrase
+        | RepeatCycle Expression [Phrase]
+        | ForCycle Identifier Expression Expression Phrase Bool -- The last Boolean indicates wether it's up or down counting
+        | WithBlock Reference Phrase
+        | Phrases [Phrase]
+        | SwitchCase Expression [([InitExpression], Phrase)] (Maybe [Phrase])
+        | Assignment Reference Expression
+        | BuiltInFunctionCall [Expression] Reference
+        | NOP
+    deriving Show
+data Expression = Expression String
+    | BuiltInFunCall [Expression] Reference
+    | PrefixOp String Expression
+    | PostfixOp String Expression
+    | BinOp String Expression Expression
+    | StringLiteral String
+    | PCharLiteral String
+    | CharCode String
+    | HexCharCode String
+    | NumberLiteral String
+    | FloatLiteral String
+    | HexNumber String
+    | Reference Reference
+    | SetExpression [Identifier]
+    | Null
+    deriving Show
+data Reference = ArrayElement [Expression] Reference
+    | FunCall [Expression] Reference
+    | TypeCast Identifier Expression
+    | SimpleReference Identifier
+    | Dereference Reference
+    | RecordField Reference Reference
+    | Address Reference
+    | RefExpression Expression
+    deriving Show
+data InitExpression = InitBinOp String InitExpression InitExpression
+    | InitPrefixOp String InitExpression
+    | InitReference Identifier
+    | InitArray [InitExpression]
+    | InitRecord [(Identifier, InitExpression)]
+    | InitFloat String
+    | InitNumber String
+    | InitHexNumber String
+    | InitString String
+    | InitChar String
+    | BuiltInFunction String [InitExpression]
+    | InitSet [InitExpression]
+    | InitAddress InitExpression
+    | InitNull
+    | InitRange Range
+    | InitTypeCast Identifier InitExpression
+    deriving Show
+
+data BaseType = BTUnknown
+    | BTChar
+    | BTString
+    | BTInt Bool -- second param indicates whether signed or not
+    | BTBool
+    | BTFloat
+    | BTRecord String [(String, BaseType)]
+    | BTArray Range BaseType BaseType
+    | BTFunction Bool [(Bool, BaseType)] BaseType -- (Bool, BaseType), Bool indiciates whether var or not
+    | BTPointerTo BaseType
+    | BTUnresolved String
+    | BTSet BaseType
+    | BTEnum [String]
+    | BTVoid
+    | BTUnit
+    | BTVarParam BaseType
+    deriving Show