Merge from default flibqtfrontend
authorunc0rr
Sun, 16 Dec 2012 12:25:13 +0400
branchflibqtfrontend
changeset 8304 620560c89284
parent 8282 1f81bcce3ee6 (current diff)
parent 8303 6331bceac95c (diff)
child 8306 50fe80adbfcb
Merge from default
CMakeLists.txt
QTfrontend/CMakeLists.txt
QTfrontend/game.cpp
QTfrontend/hwform.cpp
QTfrontend/net/hwmap.cpp
QTfrontend/net/newnetclient.cpp
hedgewars/ArgParsers.inc
hedgewars/hwengine.pas
misc/physfs/CMakeLists.txt
--- a/CMakeLists.txt	Sun Dec 16 12:05:32 2012 +0400
+++ b/CMakeLists.txt	Sun Dec 16 12:25:13 2012 +0400
@@ -105,12 +105,12 @@
     endif()
 
     #lower systems don't have enough processing power anyway
-    if (minimum_macosx_version LESS "10.4")
+    if (minimum_macosx_version VERSION_LESS "10.4")
         message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4")
     endif()
 
     #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
-    if(current_macosx_version MATCHES "10.4")
+    if(current_macosx_version VERSION_EQUAL "10.4")
         find_package(SDL_mixer REQUIRED)
         set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
         set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
@@ -120,7 +120,7 @@
 
     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
     if(NOT CMAKE_OSX_ARCHITECTURES)
-        if(current_macosx_version LESS "10.6")
+        if(current_macosx_version VERSION_LESS "10.6")
             if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*")
                 set(CMAKE_OSX_ARCHITECTURES "ppc7400")
             else()
@@ -133,8 +133,8 @@
 
     #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
     #we need to provide the correct one when host and target differ
-    if(NOT ${minimum_macosx_version} MATCHES ${current_macosx_version})
-        if(minimum_macosx_version MATCHES "10.4")
+    if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version})
+        if(minimum_macosx_version VERSION_EQUAL "10.4")
             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
             set(CMAKE_C_COMPILER "gcc-4.0")
             set(CMAKE_CXX_COMPILER "g++-4.0")
@@ -149,8 +149,10 @@
     #set deployment target
     set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags})
 
-    message(STATUS "Build system: Mac OS X ${current_macosx_version} with C compiler: ${CMAKE_C_COMPILER}")
-    message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s): ${CMAKE_OSX_ARCHITECTURES}")
+    #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
+    if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
+        set(WARNING "Video recording support before OS X 10.6 is experimental")
+    endif()
 endif(APPLE)
 
 
@@ -158,7 +160,7 @@
 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 "Only 'Debug' or 'Release' options are allowed." FORCE)
+        set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
         message (STATUS "Unknown build type, using default (${default_build_type})")
     endif ()
 else (CMAKE_BUILD_TYPE)
@@ -183,25 +185,33 @@
 
 #parse additional parameters
 if(FPFLAGS OR GHFLAGS)
-    math(EXPR cmake_version "${CMAKE_MAJOR_VERSION}*10000 + ${CMAKE_MINOR_VERSION}*100 + ${CMAKE_PATCH_VERSION}")
-    if(cmake_version LESS "020800")
-        message(STATUS "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
+    set(cmake_version "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
+    if(cmake_version VERSION_LESS "2.8")
+        message(WARNING "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
     else()
         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
     endif()
 endif()
 
-set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags})
+set(pascal_flags ${fpflags_parsed}              # user flags
+                 "-vm4079,4080,4081"            # fpc output format
+                 "-B"                           # compile all units
+                 "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory
+                 "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory
+                 "-Cs2000000"                   # stack size
+                 "-vewnq"                       # fpc output verbosity
+                 "-dDEBUGFILE"                  # macro for engine output
+                 ${pascal_flags}                # adding to list
+                 )
 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
 
 #get BUILD_TYPE and enable/disable optimisation
+message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
-    message(STATUS "Building Debug flavour")
     set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
 else()
-    message(STATUS "Building Release flavour")
 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
     set(pascal_flags "-Os" "-Xs" "-Si" ${pascal_flags})
     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
@@ -215,12 +225,13 @@
     set(SHAREPATH share/hedgewars/)
 endif()
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
+set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 if(WIN32)
     set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
     link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
 endif(WIN32)
 
+
 #server discovery
 if(NOT NOSERVER)
     if(GHC)
@@ -255,12 +266,16 @@
 endif()
 
 
+#physfs library (static on unix, dll on win32)
+add_subdirectory(misc/physfs)
+if(NOT WIN32)
+    set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
+endif()
+
+
 #main engine
 add_subdirectory(hedgewars)
 
-#physfs library
-add_subdirectory(misc/physfs)
-
 #frontend library
 add_subdirectory(project_files/frontlib)
 
--- a/QTfrontend/AutoUpdater.h	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/AutoUpdater.h	Sun Dec 16 12:25:13 2012 +0400
@@ -11,6 +11,7 @@
         virtual ~AutoUpdater();
 
         virtual void checkForUpdates() = 0;
+        virtual void checkForUpdatesNow() = 0;
 };
 
 #endif
--- a/QTfrontend/CMakeLists.txt	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/CMakeLists.txt	Sun Dec 16 12:25:13 2012 +0400
@@ -96,9 +96,9 @@
 if(MINGW)
     # resource compilation for mingw
     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o
-    COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
-    -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
-    -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
+                       COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
+                               -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
+                               -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
     set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
 else(MINGW)
     set(hwfr_src ${hwfr_src} hedgewars.rc)
@@ -144,9 +144,14 @@
 
 
 if(APPLE OR CROSSAPPLE)
-    set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
-    set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS})
-
+    find_library(iokit_framework NAMES IOKit)
+    set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS})
+    set(hwfr_src ${hwfr_src} CocoaInitializer.mm
+                             InstallController.cpp
+                             M3Panel.mm
+                             M3InstallController.m
+                             NSWorkspace_RBAdditions.m
+                             )
     if(NOT NOAUTOUPDATE)
         find_package(Sparkle)
         if(SPARKLE_FOUND)
@@ -203,9 +208,7 @@
 endif()
 
 
-if (CROSSAPPLE)
-
-else()
+if (NOT CROSSAPPLE)
     target_link_libraries(hedgewars ${HW_LINK_LIBS})
 endif()
 
--- a/QTfrontend/game.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/game.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -470,6 +470,7 @@
         }*/
 
      game->SetGameState(gsStopped);
+     game->clientDisconnected();
 
      delete game->m_poller;
 }
--- a/QTfrontend/gameuiconfig.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -191,8 +191,8 @@
 {
     // fill 2/3 of the screen desktop
     const QRect deskSize = QApplication::desktop()->screenGeometry(-1);
-    Form->resize(value("frontend/width", deskSize.width()*2/3).toUInt(),
-                 value("frontend/height", deskSize.height()*2/3).toUInt());
+    Form->resize(value("frontend/width", qMin(qMax(deskSize.width()*2/3,800),deskSize.width())).toUInt(),
+                 value("frontend/height", qMin(qMax(deskSize.height()*2/3,600),deskSize.height())).toUInt());
 
     // move the window to the center of the screen
     QPoint center = QApplication::desktop()->availableGeometry(-1).center();
@@ -233,11 +233,13 @@
     setValue("audio/volume", Form->ui.pageOptions->volumeBox->value());
 
     setValue("net/nick", netNick());
-    if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked())
-    {
-        setValue("net/passwordhash", netPasswordHash());
-        setValue("net/passwordlength", netPasswordLength());
+    if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
+	setPasswordHash(netPasswordHash());
     }
+    else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
+        clearPasswordHash();
+    }
+
     setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
     setValue("net/ip", *netHost);
     setValue("net/port", netPort);
@@ -477,6 +479,40 @@
     return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*'));
 }
 
+void GameUIConfig::clearPasswordHash() 
+{
+    setValue("net/passwordhash", QString());
+    setValue("net/passwordlength", 0);
+    setValue("net/savepassword", false); //changes the savepassword value to false in order to not let the user save an empty password in PAGE_SETUP
+    reloadValues(); //reloads the values of PAGE_SETUP
+}
+
+void GameUIConfig::setPasswordHash(const QString & passwordhash)
+{
+    setValue("net/passwordhash", passwordhash);
+    setValue("net/passwordlength", passwordhash.size()/4);
+    setNetPasswordLength(passwordhash.size()/4);  //the hash.size() is divided by 4 let PAGE_SETUP use a reasonable number of stars to display the PW
+}
+
+QString GameUIConfig::passwordHash()
+{
+    return value("net/passwordhash").toString();
+}
+
+void GameUIConfig::clearTempHash() 
+{
+    setTempHash(QString());
+}
+
+void GameUIConfig::setTempHash(const QString & temphash)
+{
+    this->temphash = temphash;
+}
+
+QString GameUIConfig::tempHash() {
+    return this->temphash;
+}
+
 // When hedgewars launches, the password field is set with null characters. If the user tries to edit the field and there are such characters, then clear the field
 bool GameUIConfig::eventFilter(QObject *object, QEvent *event)
 {
--- a/QTfrontend/gameuiconfig.h	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/gameuiconfig.h	Sun Dec 16 12:25:13 2012 +0400
@@ -52,6 +52,12 @@
         QString netNick();
         QByteArray netPasswordHash();
         int netPasswordLength();
+        void clearPasswordHash();
+        void setPasswordHash(const QString & passwordhash);
+        QString passwordHash();
+        void clearTempHash();
+        void setTempHash(const QString & temphash);
+        QString tempHash();
         void setNetPasswordLength(int passwordLength);
         bool isReducedQuality() const;
         bool isFrontendEffects() const;
@@ -87,6 +93,7 @@
         bool netPasswordIsValid();
         bool eventFilter(QObject *object, QEvent *event);
         quint8 depth;
+	QString temphash;
 };
 
 #endif
--- a/QTfrontend/hwform.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/hwform.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -96,6 +96,7 @@
 #include "playerslistmodel.h"
 
 #include "DataManager.h"
+#include "AutoUpdater.h"
 
 #ifdef __APPLE__
 #include "M3Panel.h"
@@ -149,15 +150,24 @@
 #endif
 
 #ifdef __APPLE__
-    panel = new M3Panel;
-
+    AutoUpdater* updater = NULL;
+    if (config->isAutoUpdateEnabled())
+    {
+#ifdef __APPLE__
 #ifdef SPARKLE_ENABLED
-    AutoUpdater* updater;
+        updater = new SparkleAutoUpdater();
+#endif
+#endif
+        if (updater)
+        {
+            updater->checkForUpdates();
+            delete updater;
+        }
+    }
+#endif
 
-    updater = new SparkleAutoUpdater();
-    if (updater && config->isAutoUpdateEnabled())
-        updater->checkForUpdates();
-#endif
+#ifdef __APPLE__
+    panel = new M3Panel;
 
     QShortcut *hideFrontend = new QShortcut(QKeySequence("Ctrl+M"), this);
     connect (hideFrontend, SIGNAL(activated()), this, SLOT(showMinimized()));
@@ -1033,8 +1043,8 @@
 void HWForm::NetPassword(const QString & nick)
 {
     //Get hashes
-    QString hash =  config->value("net/passwordhash", "").toString();
-    QString temphash =  config->value("net/temppasswordhash", "").toString();
+    QString hash =  config->passwordHash();
+    QString temphash =  config->tempHash();
 
     //Check them
 
@@ -1049,9 +1059,61 @@
     }
 
     //Remove temporary hash from config
-    QString key = "net/temppasswordhash";
-    config->setValue(key, "");
-    config->remove(key);
+    config->clearTempHash();
+}
+
+void HWForm::NetNickRegistered(const QString & nick)
+{
+    //Get hashes
+    QString hash =  config->passwordHash();
+    QString temphash =  config->tempHash();
+
+    if (hash.isEmpty()) {
+        if (temphash.isEmpty()) { //If the user enters a registered nick with no password
+            QString suppliedpass;
+            while (suppliedpass.isEmpty()) {
+                QInputDialog nickRegedDialog(this);
+                nickRegedDialog.setWindowModality(Qt::WindowModal);
+                nickRegedDialog.setInputMode(QInputDialog::TextInput);
+                nickRegedDialog.setWindowTitle(tr("Hedgewars - Nick registered"));
+                nickRegedDialog.setLabelText(tr("This nick is registered, and you haven't specified a password.\n\nIf this nick isn't yours, please register your own nick at www.hedgewars.org\n\nPassword:"));
+                nickRegedDialog.setTextEchoMode(QLineEdit::Password);
+                nickRegedDialog.exec();
+
+                suppliedpass = nickRegedDialog.textValue();
+
+                if (nickRegedDialog.result() == QDialog::Rejected) {
+                    config->clearPasswordHash();
+                    config->clearTempHash();
+                    GoBack();
+                    return;
+                }
+                temphash = QCryptographicHash::hash(suppliedpass.toUtf8(), QCryptographicHash::Md5).toHex();
+                config->setTempHash(temphash);
+            }
+        }
+    }
+    NetPassword(nick);
+}
+
+void HWForm::NetNickNotRegistered(const QString & nick)
+{
+    QMessageBox noRegMsg(this);
+    noRegMsg.setIcon(QMessageBox::Information);
+    noRegMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Nick not registered"));
+    noRegMsg.setWindowModality(Qt::WindowModal);
+    noRegMsg.setText(tr("Your nickname is not registered.\nTo prevent someone else from using it,\nplease register it at www.hedgewars.org"));
+
+    if (!config->passwordHash().isEmpty())
+    {
+        config->clearPasswordHash();
+        noRegMsg.setText(noRegMsg.text()+tr("\n\nYour password wasn't saved either."));
+    }
+    if (!config->tempHash().isEmpty())
+    {
+        config->clearTempHash();
+    }
+    noRegMsg.exec();
 }
 
 void HWForm::NetNickTaken(const QString & nick)
@@ -1061,7 +1123,12 @@
 
     if (!ok || newNick.isEmpty())
     {
-        ForcedDisconnect(tr("No nickname supplied."));
+        //ForcedDisconnect(tr("No nickname supplied."));
+	bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
+	GoBack();
+        if (retry) {
+       	   NetConnectOfficialServer();
+        }
         return;
     }
 
@@ -1076,8 +1143,39 @@
 void HWForm::NetAuthFailed()
 {
     // Set the password blank if case the user tries to join and enter his password again
-    config->setValue("net/passwordlength", 0);
-    config->setNetPasswordLength(0);
+    config->clearTempHash();
+
+    //Try to login again
+    bool retry = RetryDialog(tr("Hedgewars - Wrong password"), tr("You entered a wrong password."));
+    GoBack();
+
+    config->clearPasswordHash();
+    config->clearTempHash();
+    if (retry) {
+       NetConnectOfficialServer();
+    }
+}
+
+bool HWForm::RetryDialog(const QString & title, const QString & label)
+{
+    QMessageBox retryMsg(this);
+    retryMsg.setIcon(QMessageBox::Warning);
+    retryMsg.setWindowTitle(title);
+    retryMsg.setText(label);
+    retryMsg.setWindowModality(Qt::WindowModal);
+
+    retryMsg.addButton(QMessageBox::Cancel);
+
+    QPushButton *retryButton = retryMsg.addButton(QMessageBox::Ok);
+    retryButton->setText(tr("Try Again"));
+    retryButton->setFocus();
+
+    retryMsg.exec();
+
+    if (retryMsg.clickedButton() == retryButton) {
+       return true;
+    }
+    return false;
 }
 
 void HWForm::NetTeamAccepted(const QString & team)
@@ -1130,7 +1228,8 @@
     connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(RemoveNetTeam(const HWTeam&)), this, SLOT(RemoveNetTeam(const HWTeam&)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(TeamAccepted(const QString&)), this, SLOT(NetTeamAccepted(const QString&)), Qt::QueuedConnection);
-    connect(hwnet, SIGNAL(AskForPassword(const QString&)), this, SLOT(NetPassword(const QString&)), Qt::QueuedConnection);
+    connect(hwnet, SIGNAL(NickRegistered(const QString&)), this, SLOT(NetNickRegistered(const QString&)), Qt::QueuedConnection);
+    connect(hwnet, SIGNAL(NickNotRegistered(const QString&)), this, SLOT(NetNickNotRegistered(const QString&)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)), Qt::QueuedConnection);
     connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection);
     //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
@@ -1250,78 +1349,86 @@
     connect(hwnet, SIGNAL(paramChanged(const QString &, const QStringList &)), ui.pageNetGame->pGameCFG, SLOT(setParam(const QString &, const QStringList &)));
     connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &)));
     connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig()));
-   
+
 //nick and pass stuff
-    
+
     //remove temppasswordhash just in case
-    config->value("net/temppasswordhash", "");
-    config->remove("net/temppasswordhash");
-    
+    config->clearTempHash();
+
     //initialize
-    QString hash = config->value("net/passwordhash", "").toString();
-    QString temphash = config->value("net/temppasswordhash", "").toString();
+    QString hash = config->passwordHash();
+    QString temphash = config->tempHash();
     QString nickname = config->value("net/nick", "").toString();
     QString password;
-    
+
     if (nickname.isEmpty() || hash.isEmpty()) { //if something from login is missing, start dialog loop
-    
-    while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing
-    {
-	//open dialog
-        HWPasswordDialog * hpd = new HWPasswordDialog(this);
-        hpd->cbSave->setChecked(config->value("net/savepassword", true).toBool());
+
+        while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing
+        {
+        //open dialog
+            HWPasswordDialog * pwDialog = new HWPasswordDialog(this);
+            pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool());
 
-	//if nickname is present, put it into the field
-	if (!nickname.isEmpty()) {
-	    hpd->leNickname->setText(nickname);
-	    hpd->lePassword->setFocus();
-	}
+        //if nickname is present, put it into the field
+        if (!nickname.isEmpty()) {
+            pwDialog->leNickname->setText(nickname);
+            pwDialog->lePassword->setFocus();
+        }
 
-	//if dialog close, create an error message
-        if (hpd->exec() != QDialog::Accepted)
-        {
-            ForcedDisconnect(tr("Login info not supplied."));
-            delete hpd;
+        //if dialog close, create an error message
+        if (pwDialog->exec() != QDialog::Accepted) {
+            delete pwDialog;
+            GoBack();
             return;
         }
 
-	//set nick and pass from the dialog
-	nickname = hpd->leNickname->text();
-        password = hpd->lePassword->text();
-
-	//calculate temphash and set it into config
-	temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
-	config->setValue("net/temppasswordhash", temphash);
+        //set nick and pass from the dialog
+        nickname = pwDialog->leNickname->text();
+        password = pwDialog->lePassword->text();
 
-	//if user wants to save password
-        bool save = hpd->cbSave->isChecked();
-        config->setValue("net/savepassword", save);
-        if (save) // user wants to save password
-        {
-            config->setValue("net/passwordhash", temphash);
-            config->setValue("net/passwordlength", password.size());
-            config->setNetPasswordLength(password.size());
+        //check the nickname variable
+        if (nickname.isEmpty()) {
+            int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
+            GoBack();
+            delete pwDialog;
+            if (retry) {
+                NetConnectOfficialServer();
+            }
+            return;
         }
 
-        delete hpd;
+        if (!password.isEmpty()) {
+            //calculate temphash and set it into config
+            temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
+            config->setTempHash(temphash);
 
+            //if user wants to save password
+            bool save = pwDialog->cbSave->isChecked();
+            config->setValue("net/savepassword", save);
+            if (save) // user wants to save password
+            {
+                config->setPasswordHash(temphash);
+            }
+        }
+        else {
+            delete pwDialog;
+            config->setValue("net/nick", nickname);
+            config->updNetNick();
+            config->clearPasswordHash();
+            break;
+        }
 
-	//update nickname
+        delete pwDialog;
+
+        //update nickname
         config->setValue("net/nick", nickname);
         config->updNetNick();
-	
-	//and all the variables
-	hash = config->value("net/passwordhash", "").toString();
-	temphash = config->value("net/temppasswordhash", "").toString();
-	nickname = config->value("net/nick", "").toString();
-    }
-    
-    
-	//if pass is none (hash is generated anyway), remove the hash
-	if (password.size() <= 0) {
-	    config->setValue("net/temppasswordhash", "");
-	    config->remove("net/temppasswordhash");
-	}
+
+        //and all the variables
+        hash = config->passwordHash();
+        temphash = config->tempHash();
+        nickname = config->value("net/nick", "").toString();
+        }
     }
 
     ui.pageRoomsList->setUser(nickname);
@@ -1396,6 +1503,21 @@
 
 void HWForm::ForcedDisconnect(const QString & reason)
 {
+    if (reason == "Reconnected too fast") { //TODO: this is a hack, which should be remade
+        bool retry = RetryDialog(tr("Hedgewars - Connection error"), tr("You reconnected too fast.\nPlease wait a few seconds and try again."));
+        if (retry) {
+            NetConnectOfficialServer();
+        }
+        else {
+            while (ui.Pages->currentIndex() != ID_PAGE_NET
+                && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
+                && ui.Pages->currentIndex() != ID_PAGE_MAIN) 
+            {
+                GoBack();
+            }
+        }
+        return;
+    }
     if (pnetserver)
         return; // we have server - let it care of all things
     if (hwnet)
@@ -1500,7 +1622,7 @@
 void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo)
 {
     game = new HWGame(config, gamecfg, ammo, pTeamSelWidget);
-    connect(game, SIGNAL(CampStateChanged(int)), this, SLOT(UpdateCampaignPageProgress(int)));
+    connect(game, SIGNAL(campStateChanged(int)), this, SLOT(UpdateCampaignPageProgress(int)));
     connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState)));
     connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &)));
     connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
@@ -1759,19 +1881,25 @@
 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
 QString HWForm::getDemoArguments()
 {
+#ifdef Q_WS_WIN
+    QString userdir = cfgdir->absolutePath().replace("/","\\");
+#else
+    QString userdir = cfgdir->absolutePath();
+#endif
+
     QRect resolution = config->vid_Resolution();
-    return QString(QString::number(resolution.width()) + " "
-                   + QString::number(resolution.height()) + " "
-                   + QString::number(config->bitDepth()) + " " // bpp
-                   + QString::number(config->volume()) + " " // sound volume
-                   + (config->isMusicEnabled() ? "1" : "0") + " "
-                   + (config->isSoundEnabled() ? "1" : "0") + " "
-                   + config->language() + ".txt "
-                   + (config->vid_Fullscreen() ? "1" : "0") + " "
-                   + (config->isShowFPSEnabled() ? "1" : "0") + " "
-                   + (config->isAltDamageEnabled() ? "1" : "0") + " "
-                   + QString::number(config->timerInterval()) + " "
-                   + QString::number(config->translateQuality()));
+    return QString("--user-dir " + userdir
+                   + " --width " + QString::number(resolution.width())
+                   + " --height " + QString::number(resolution.height())
+                   + " --volume " + QString::number(config->volume())
+                   + (config->isMusicEnabled() ? "" : " --nomusic")
+                   + (config->isSoundEnabled() ? "" : " --nosound")
+                   + " --locale " + config->language() + ".txt"
+                   + (config->vid_Fullscreen() ? " --fullscreen" : "")
+                   + (config->isShowFPSEnabled() ? " --showfps" : "")
+                   + (config->isAltDamageEnabled() ? " --altdmg" : "")
+                   + " --frame-interval " + QString::number(config->timerInterval())
+                   + " --raw-quality " + QString::number(config->translateQuality()));
 }
 
 void HWForm::AssociateFiles()
@@ -1786,8 +1914,8 @@
     registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types"));
     registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0");
     registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0");
-    registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments);
-    registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments);
+    registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
+    registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
 #elif defined __APPLE__
     // only useful when other apps have taken precedence over our file extensions and you want to reset it
     system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hwd</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
@@ -1808,7 +1936,7 @@
     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0;
     if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0;
     // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home.  This assumes no spaces in the data dir path
-    if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0;
+    if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 \\2 "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0;
 #endif
     if (success)
     {
--- a/QTfrontend/hwform.h	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/hwform.h	Sun Dec 16 12:25:13 2012 +0400
@@ -105,8 +105,11 @@
         void NetWarning(const QString & wrnmsg);
         void NetGameEnter();
         void NetPassword(const QString & nick);
+        void NetNickRegistered(const QString & nick);
+        void NetNickNotRegistered(const QString & nick);
         void NetNickTaken(const QString & nick);
         void NetAuthFailed();
+	bool RetryDialog(const QString & title, const QString & label);
         void NetTeamAccepted(const QString& team);
         void AddNetTeam(const HWTeam& team);
         void RemoveNetTeam(const HWTeam& team);
--- a/QTfrontend/net/hwmap.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/net/hwmap.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -101,6 +101,8 @@
 {
     HWMap * hwMap = (HWMap *)context;
 
+    qWarning(errormessage);
+
     hwMap->clientDisconnected();
 }
 
--- a/QTfrontend/net/newnetclient.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -241,6 +241,7 @@
     {
         mynick = lst[1];
         m_playersModel->setNickname(mynick);
+        m_nick_registered = false;
         return ;
     }
 
@@ -304,6 +305,10 @@
         QStringList tmp = lst;
         tmp.removeFirst();
         m_roomsListModel->setRoomsList(tmp);
+        if (m_nick_registered == false)
+        {
+            emit NickNotRegistered(mynick);
+        }
         return;
     }
 
@@ -538,7 +543,8 @@
 
     if (lst[0] == "ASKPASSWORD")
     {
-        emit AskForPassword(mynick);
+        emit NickRegistered(mynick);
+        m_nick_registered = true;
         return;
     }
 
@@ -573,6 +579,10 @@
         if (lst[1] == "Authentication failed")
         {
             emit AuthFailed();
+	    m_game_connected = false;
+	    Disconnect();
+	    //omitted 'emit disconnected()', we don't want the error message
+	    return;
         }
         m_game_connected = false;
         Disconnect();
@@ -629,6 +639,12 @@
             return;
         }
 
+        if (lst[0] == "ROUND_FINISHED")
+        {
+            emit FromNet(QByteArray("\x01o"));
+            return;
+        }
+
         if (lst[0] == "ADD_TEAM")
         {
             if(lst.size() != 24)
--- a/QTfrontend/net/newnetclient.h	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/net/newnetclient.h	Sun Dec 16 12:25:13 2012 +0400
@@ -69,6 +69,7 @@
         QTcpSocket NetSocket;
         QString seed;
         bool m_game_connected;
+        bool m_nick_registered;
         RoomsListModel * m_roomsListModel;
         PlayersListModel * m_playersModel;
         QSortFilterProxyModel * m_lobbyPlayersModel;
@@ -90,7 +91,8 @@
         void disconnected(const QString & reason);
         void Error(const QString & errmsg);
         void Warning(const QString & wrnmsg);
-        void AskForPassword(const QString & nick);
+        void NickRegistered(const QString & nick);
+        void NickNotRegistered(const QString & nick);
         void NickTaken(const QString & nick);
         void AuthFailed();
         void EnteredGame();
--- a/QTfrontend/ui/page/pagefeedback.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/ui/page/pagefeedback.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -59,11 +59,13 @@
     info = new QLabel();
     info->setText(
         "<style type=\"text/css\">"
-        "a { color: #ffcc00; }"
+        "a { color: #fc0; }"
+        "b { color: #0df; }"
         "</style>"
         "<div align=\"center\"><h1>Please give us a feedback!</h1>"
         "<h3>We are always happy about suggestions, ideas or bug reports.<h3>"
-        "<h4>The feedback will be posted as a new issue on our Google Code page.<h4>"
+        "<h4>The feedback will be posted as a new issue on our Google Code page.<br />"
+        "<b>Don't forget to mention your email or you won't be able to receive updates on this topic!</b><br /></h4>"
         //"<h4>Your email is optional, but if given, you will be notified of responses.<h4>"
         "</div>"
     );
@@ -86,8 +88,12 @@
     //  It's sent in the XML as a <issues:cc> , the <entry>, but it doesn't seem
     //  to actually do anything. If you figure out how to fix that, uncomment these lines
     //  and the line above in the 'info' QLabel to re-enable this feature.
+    //  UPDATE: I found out that CC only works if that email is a member of the
+    //  Google Code project. So this feature is pretty much useless atm.
+    /*
     combinedTopLayout->addLayout(emailLayout);
     combinedTopLayout->insertSpacing(1, 50);
+    */
 
     pageLayout->addLayout(combinedTopLayout);
 
@@ -197,8 +203,8 @@
 #endif
 
     // cpu info
-    uint32_t registers[4];
-    uint32_t i;
+    quint32 registers[4];
+    quint32 i;
 
     i = 0x80000002;
     asm volatile
@@ -239,7 +245,6 @@
 
     // add everything to the field of text
     description->setText(
-        "Don't forget to mention your email or you won't be able to receive updates on this topic!"
         "\n\n\n\n\n"
         "System information:\n"
         + qt_version
--- a/QTfrontend/ui/page/pagemain.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/ui/page/pagemain.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -59,10 +59,12 @@
     pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
 
     BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false);
+    BtnFeedback->setFixedSize(86, 27);
     BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars"));
     pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter);
 
     BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false);
+    BtnDataDownload->setFixedSize(176, 27);
     //BtnDataDownload->setToolTip(tr(Downloadable Content"));
     BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website"));
     pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter);
--- a/QTfrontend/ui/page/pageoptions.cpp	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/ui/page/pageoptions.cpp	Sun Dec 16 12:25:13 2012 +0400
@@ -39,6 +39,13 @@
 #include "igbox.h"
 #include "DataManager.h"
 #include "LibavInteraction.h"
+#include "AutoUpdater.h"
+
+#ifdef __APPLE__
+#ifdef SPARKLE_ENABLED
+#include "SparkleAutoUpdater.h"
+#endif
+#endif
 
 // TODO cleanup
 QLayout * PageOptions::bodyLayoutDefinition()
@@ -231,7 +238,14 @@
     #ifdef SPARKLE_ENABLED
             CBAutoUpdate = new QCheckBox(groupMisc);
             CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup"));
-            MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3);
+            MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 1);
+
+            btnUpdateNow = new QPushButton(groupMisc);
+            connect(btnUpdateNow, SIGNAL(clicked()), this, SLOT(checkForUpdates()));
+            btnUpdateNow->setToolTip(tr("Check for updates"));
+            btnUpdateNow->setText("Check now");
+            btnUpdateNow->setFixedSize(130, 30);
+            MiscLayout->addWidget(btnUpdateNow, 7, 1, 1, 1);
     #endif
     #endif
             page1Layout->addWidget(groupMisc, 2, 0);
@@ -859,6 +873,23 @@
     setDefaultCodecs();
 }
 
+void PageOptions::checkForUpdates()
+{
+    AutoUpdater *updater = NULL;
+
+#ifdef __APPLE__
+#ifdef SPARKLE_ENABLED
+    updater = new SparkleAutoUpdater();
+#endif
+#endif
+
+    if (updater)
+    {
+        updater->checkForUpdatesNow();
+        delete updater;
+    }
+}
+
 bool PageOptions::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec)
 {
     // first we should change format
--- a/QTfrontend/ui/page/pageoptions.h	Sun Dec 16 12:05:32 2012 +0400
+++ b/QTfrontend/ui/page/pageoptions.h	Sun Dec 16 12:25:13 2012 +0400
@@ -70,6 +70,7 @@
         QCheckBox *CBNameWithDate;
 #ifdef __APPLE__
         QCheckBox *CBAutoUpdate;
+        QPushButton *BtnUpdateNow;
 #endif
 
         FPSEdit *fpsedit;
@@ -131,6 +132,7 @@
         QComboBox *comboVideoCodecs;
         QComboBox *comboAudioCodecs;
         QPushButton *btnDefaults;
+        QPushButton *btnUpdateNow;
         GameUIConfig * config;
 
     private slots:
@@ -148,6 +150,7 @@
         void changeAVFormat(int index);
         void changeUseGameRes(int state);
         void changeRecordAudio(int state);
+        void checkForUpdates();
 
     public slots:
         void setDefaultOptions();
--- a/cmake_modules/FindFFMPEG.cmake	Sun Dec 16 12:05:32 2012 +0400
+++ b/cmake_modules/FindFFMPEG.cmake	Sun Dec 16 12:25:13 2012 +0400
@@ -16,17 +16,23 @@
 #  BSD license.
 #
 
+set(FFMPEG_FOUND FALSE)
+
 if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
   # in cache already
   set(FFMPEG_FOUND TRUE)
 else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
+  # silence output option
+  if (FFMPEG_FIND_QUIETLY)
+    set(VERBOSITY "QUIET")
+  endif ()
   # 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)
-    pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
-    pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
-    pkg_check_modules(_FFMPEG_AVUTIL libavutil)
+    pkg_check_modules(_FFMPEG_AVCODEC libavcodec ${VERBOSITY})
+    pkg_check_modules(_FFMPEG_AVFORMAT libavformat ${VERBOSITY})
+    pkg_check_modules(_FFMPEG_AVUTIL libavutil ${VERBOSITY})
   endif (PKG_CONFIG_FOUND)
 
   find_path(FFMPEG_AVCODEC_INCLUDE_DIR
@@ -74,10 +80,6 @@
       ${FFMPEG_LIBAVFORMAT}
       ${FFMPEG_LIBAVUTIL}
     )
-    if (APPLE)
-      set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "bz2" "-framework CoreVideo" "-framework VideoDecodeAcceleration")
-    endif(APPLE)
-
   endif (FFMPEG_FOUND)
 
   if (FFMPEG_FOUND)
--- a/cmake_modules/FindFreepascal.cmake	Sun Dec 16 12:05:32 2012 +0400
+++ b/cmake_modules/FindFreepascal.cmake	Sun Dec 16 12:25:13 2012 +0400
@@ -13,12 +13,13 @@
 
     string(REGEX MATCH "[0-9]+\\.[0-9]+" FPC_VERSION_LONG "${FPC_VERSION_FULL}")
     string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" FPC_VERSION "${FPC_VERSION_LONG}")
-    message(STATUS "Found Freepascal: ${FPC_EXECUTABLE} (version ${FPC_VERSION}")
+    message(STATUS "Found Freepascal: ${FPC_EXECUTABLE} (version ${FPC_VERSION})")
 else()
     message(FATAL_ERROR "Could NOT find Freepascal")
 endif()
 
 # Check for noexecstack flag support
+message(STATUS "Checking whether linker needs explicit noexecstack")
 set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack")
 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
 
--- a/hedgewars/ArgParsers.inc	Sun Dec 16 12:05:32 2012 +0400
+++ b/hedgewars/ArgParsers.inc	Sun Dec 16 12:25:13 2012 +0400
@@ -75,32 +75,26 @@
 begin
     WriteLn(stdout, 'Usage:');
     WriteLn(stdout, '');
-    WriteLn(stdout, '  hwengine [path to user hedgewars folder] <path to global data folder> <path to replay file> [options]');
+    WriteLn(stdout, '  hwengine <path to global data folder> <path to replay file> [options]');
     WriteLn(stdout, '');
     WriteLn(stdout, 'where [options] are any of the following:');
-    WriteLn(stdout, ' --locale [path to language file]');
-    WriteLn(stdout, ' --width  [screen width in pixels]');
+    WriteLn(stdout, ' --user-dir [path to user data folder]');
+    WriteLn(stdout, ' --locale [name of language file]');
+    WriteLn(stdout, ' --width [screen width in pixels]');
     WriteLn(stdout, ' --height [screen height in pixels]');
-    WriteLn(stdout, ' --depth  [color depth]');
     WriteLn(stdout, ' --volume [sound level]');
-    WriteLn(stdout, ' --time   [number of seconds]');
+    WriteLn(stdout, ' --frame-interval [milliseconds]');
+    WriteLn(stdout, ' --raw-quality [flags]');
+    WriteLn(stdout, ' --low-quality');
     WriteLn(stdout, ' --nomusic');
     WriteLn(stdout, ' --nosound');
     WriteLn(stdout, ' --fullscreen');
     WriteLn(stdout, ' --showfps');
     WriteLn(stdout, ' --altdmg');
-    WriteLn(stdout, ' --lowquality');
     WriteLn(stdout, ' --stats-only');
     WriteLn(stdout, ' --help');
     WriteLn(stdout, '');
-    WriteLn(stdout, 'Deprecated options:');
-    WriteLn(stdout, ' --set-video [screen width] [screen height] [color dept]');
-    WriteLn(stdout, ' --set-audio [volume] [enable music] [enable sounds]');
-    WriteLn(stdout, ' --set-other [language file] [full screen] [show FPS]');
-    WriteLn(stdout, ' --set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]');
-    WriteLn(stdout, ' --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]');
-    WriteLn(stdout, '');
-    WriteLn(stdout, 'For a more detailed help and examples go to:');
+    WriteLn(stdout, 'For more detailed help and examples go to:');
     WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions');
 end;
 
@@ -115,12 +109,16 @@
     getLongIntParameter:= tmpInt;
 end;
 
-function getStringParameter(str:String; var paramIndex:LongInt): String;
+function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String;
 begin
     paramIndex:= paramIndex + 1;
+    wrongParameter:= (str='') or (Copy(str,1,2) = '--');
+    if wrongParameter then
+         WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"');
     getStringParameter:= str;
 end;
 
+
 procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward;
 
 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean;
@@ -129,60 +127,67 @@
 const otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
 const mediaArray: Array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen');
 const allArray: Array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--time','--lowquality');
-const reallyAll: array[0..19] of shortstring = (
-            '--locale', '--width', '--height', '--depth', '--time'
-            , '--volume', '--nomusic', '--nosound', '--fullscreen', '--showfps'
-            , '--altdmg', '--lowquality', '--set-video', '--set-audio', '--set-other'
-            , '--set-multimedia', '--set-everything', '--stats-only', '--gci', '--help');
+const reallyAll: array[0..21] of shortstring = (
+                '--user-dir', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
+                '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality',
+  {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
+                '--stats-only', '--gci', '--help');
 var cmdIndex: byte;
 begin
     parseParameter:= false;
     cmdIndex:= 0;
+
+    //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above,
+    //      the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki
+
     while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex);
     case cmdIndex of
-        {--locale}   0 : cLocaleFName   := getStringParameter (arg, paramIndex);
-        {--width}    1 : cScreenWidth   := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--height}   2 : cScreenHeight  := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--depth}    3 : cBits          := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--time}     4 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--volume}   5 : SetVolume       ( getLongIntParameter(arg, paramIndex, parseParameter) );
-        {--nomusic}  6 : SetMusic        ( false );
-        {--nosound}  7 : SetSound        ( false );
-        {--fullscreen}   8 : cFullScreen    := true;
-        {--showfps}      9 : cShowFPS       := true;
-        {--altdmg}      10 : cAltDamage     := true;
-        {--lowquality}  11 : cReducedQuality:= ($FFFFFFFF * getLongIntParameter(arg, paramIndex, parseParameter)) xor rqLowRes; //HACK!
-        {--set-video}   12 : parseClassicParameter(videoArray,3,paramIndex);
-        {--set-audio}   13 : parseClassicParameter(audioArray,3,paramIndex);
-        {--set-other}   14 : parseClassicParameter(otherArray,3,paramIndex);
-        {--set-multimedia}  15 : parseClassicParameter(mediaArray,8,paramIndex);
-        {--set-everything}  16 : parseClassicParameter(allArray,12,paramIndex);
-        {--stats-only}  17 : begin
-                             cOnlyStats:= true;
-                             SetSound(false);
-                             SetMusic(false);
-                             cReducedQuality:= $FFFFFFFF xor rqLowRes;
-                             end;
-        {--gci}  18 : begin            //     We had to make up all this saved space some how...     \\
-                      WriteLn(stdout, '                                                                ');
-                      WriteLn(stdout, '      /\\\\\\\\\\\\        /\\\\\\\\\  /\\\\\\\\\\\             ');
-                      WriteLn(stdout, '     /\\\//////////      /\\\////////  \/////\\\///             ');
-                      WriteLn(stdout, '     /\\\               /\\\/               \/\\\               ');
-                      WriteLn(stdout, '     \/\\\    /\\\\\\\  /\\\                 \/\\\              ');
-                      WriteLn(stdout, '      \/\\\   \/////\\\ \/\\\                 \/\\\             ');
-                      WriteLn(stdout, '       \/\\\       \/\\\ \//\\\                \/\\\            ');
-                      WriteLn(stdout, '        \/\\\       \/\\\  \///\\\              \/\\\           ');
-                      WriteLn(stdout, '         \//\\\\\\\\\\\\/     \////\\\\\\\\\  /\\\\\\\\\\\      ');
-                      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;
-        {--help}  19 : begin
-                       DisplayUsage();
-                       GameType:= gmtSyntax;
-                       end;
+        {--user-dir}        0 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter);
+        {--locale}          1 : cLocaleFName   := getStringParameter (arg, paramIndex, parseParameter);
+        {--width}           2 : cScreenWidth   := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--height}          3 : cScreenHeight  := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--frame-interval}  4 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--volume}          5 : SetVolume       ( getLongIntParameter(arg, paramIndex, parseParameter) );
+        {--nomusic}         6 : SetMusic        ( false );
+        {--nosound}         7 : SetSound        ( false );
+        {--fullscreen}      8 : cFullScreen    := true;
+        {--showfps}         9 : cShowFPS       := true;
+        {--altdmg}         10 : cAltDamage     := true;
+        {--low-quality}    11 : cReducedQuality:= $FFFFFFFF xor rqLowRes;
+        {--raw-quality}    12 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter);
+        {deprecated options}
+        {--depth}          13 : cBits          := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--set-video}      14 : parseClassicParameter(videoArray,3,paramIndex);
+        {--set-audio}      15 : parseClassicParameter(audioArray,3,paramIndex);
+        {--set-other}      16 : parseClassicParameter(otherArray,3,paramIndex);
+        {--set-multimedia} 17 : parseClassicParameter(mediaArray,8,paramIndex);
+        {--set-everything} 18 : parseClassicParameter(allArray,12,paramIndex);
+        {anything else}
+        {--stats-only}     19 : begin
+                                cOnlyStats:= true;
+                                cReducedQuality:= $FFFFFFFF xor rqLowRes;
+                                SetSound(false);
+                                end;
+        {--gci}            20 : begin            //     We had to make up all this saved space some how...     \\
+                                WriteLn(stdout, '                                                                ');
+                                WriteLn(stdout, '      /\\\\\\\\\\\\        /\\\\\\\\\  /\\\\\\\\\\\             ');
+                                WriteLn(stdout, '     /\\\//////////      /\\\////////  \/////\\\///             ');
+                                WriteLn(stdout, '     /\\\               /\\\/               \/\\\               ');
+                                WriteLn(stdout, '     \/\\\    /\\\\\\\  /\\\                 \/\\\              ');
+                                WriteLn(stdout, '      \/\\\   \/////\\\ \/\\\                 \/\\\             ');
+                                WriteLn(stdout, '       \/\\\       \/\\\ \//\\\                \/\\\            ');
+                                WriteLn(stdout, '        \/\\\       \/\\\  \///\\\              \/\\\           ');
+                                WriteLn(stdout, '         \/\\\\\\\\\\\\\/     \////\\\\\\\\\  /\\\\\\\\\\\      ');
+                                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;
+        {--help}           21 : begin
+                                DisplayUsage();
+                                GameType:= gmtSyntax;
+                                end;
     else
         begin
         WriteLn(stderr, 'ERROR: '+cmd+' is not a valid argument');
@@ -206,7 +211,7 @@
             or (cmdArray[index] = '--fullscreen')
             or (cmdArray[index] = '--showfps')
             or (cmdArray[index] = '--altdmg')
-            or (cmdArray[index] = '--lowquality');
+            or (cmdArray[index] = '--low-quality');
         if (not isBool) or ((ParamStr(paramIndex)='1') and (cmdArray[index]<>'--nomusic') and (cmdArray[index]<>'--nosound')) then
             parseParameter(cmdArray[index], ParamStr(paramIndex), tmpInt);
         index:= index+1;
--- a/hedgewars/CMakeLists.txt	Sun Dec 16 12:05:32 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Sun Dec 16 12:25:13 2012 +0400
@@ -143,7 +143,6 @@
 
         set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags})
     endif()
-    set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
 endif(APPLE)
 
 if(NOT NOPNG)
@@ -200,7 +199,6 @@
     message(STATUS "Video recording disabled by user")
 endif()
 
-set(pascal_flags "-Fl${LIBRARY_OUTPUT_PATH}" ${pascal_flags})
 
 set(fpc_flags ${NOEXECSTACK_FLAGS} ${pascal_flags} ${hwengine_project})
 
--- a/hedgewars/hwengine.pas	Sun Dec 16 12:05:32 2012 +0400
+++ b/hedgewars/hwengine.pas	Sun Dec 16 12:25:13 2012 +0400
@@ -590,21 +590,11 @@
         begin
         if (ParamCount >= 2) then
             begin
-            UserPathPrefix := ParamStr(1);
-            PathPrefix     := ParamStr(2);
-            end;
-        if (ParamCount >= 3) then
-            recordFilename := ParamStr(3);
-        if (ParamCount = 2) or
-           ((ParamCount >= 3) and (Copy(recordFileName,1,2) = '--')) then
-            begin
             UserPathPrefix := '.';
             PathPrefix     := ParamStr(1);
             recordFileName := ParamStr(2);
             startIndex     := 3;
-            end
-        else
-            startIndex := 4;
+            end;
 
         playReplayFileWithParameters(startIndex);
         end;
--- a/hedgewars/uPhysFSLayer.pas	Sun Dec 16 12:05:32 2012 +0400
+++ b/hedgewars/uPhysFSLayer.pas	Sun Dec 16 12:25:13 2012 +0400
@@ -15,7 +15,6 @@
 {$IFDEF WIN32}
     PhysfsLibName = 'libphysfs';
 {$ELSE}
-    {$LINKLIB ../bin/libphysfs.a}
     PhysfsLibName = 'physfs';
 {$ENDIF}
 
--- a/hedgewars/uVideoRec.pas	Sun Dec 16 12:05:32 2012 +0400
+++ b/hedgewars/uVideoRec.pas	Sun Dec 16 12:25:13 2012 +0400
@@ -30,11 +30,6 @@
 {$IFNDEF WIN32}
     {$LINKLIB ../bin/libavwrapper.a}
 {$ENDIF}
-{$IFDEF DARWIN}
-    {$LINKLIB bz2}
-    {$LINKFRAMEWORK CoreVideo}
-    {$LINKFRAMEWORK VideoDecodeAcceleration}
-{$ENDIF}
 
 interface
 
--- a/misc/physfs/CMakeLists.txt	Sun Dec 16 12:05:32 2012 +0400
+++ b/misc/physfs/CMakeLists.txt	Sun Dec 16 12:25:13 2012 +0400
@@ -6,59 +6,61 @@
 #lines overridden by Hedgewars configuration
 #CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
 #PROJECT(PhysicsFS)
-set(PHYSFS_VERSION 2.1.0)
+SET(PHYSFS_VERSION 2.1.0)
 
 # Increment this if/when we break backwards compatibility.
-set(PHYSFS_SOVERSION 1)
+SET(PHYSFS_SOVERSION 1)
 
 # I hate that they define "WIN32" ... we're about to move to Win64...I hope!
-if(WIN32 AND NOT WINDOWS)
-    set(WINDOWS true)
-endif(WIN32 AND NOT WINDOWS)
+IF(WIN32 AND NOT WINDOWS)
+    SET(WINDOWS TRUE)
+ENDIF(WIN32 AND NOT WINDOWS)
+
 
 # Bleh, let's do it for "APPLE" too.
-if(APPLE AND NOT MACOSX)
-    set(MACOSX true)
-endif(APPLE AND NOT MACOSX)
+IF(APPLE AND NOT MACOSX)
+    SET(MACOSX TRUE)
+ENDIF(APPLE AND NOT MACOSX)
 
 # For now, Haiku and BeOS are the same, as far as the build system cares.
-if(HAIKU AND NOT BEOS)
-    set(BEOS true)
-endif(HAIKU AND NOT BEOS)
+IF(HAIKU AND NOT BEOS)
+    SET(BEOS TRUE)
+ENDIF(HAIKU AND NOT BEOS)
 
-if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
-    set(SOLARIS true)
-endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+    SET(SOLARIS TRUE)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
-include(CheckIncludeFile)
-include(CheckLibraryExists)
-include(CheckCSourceCompiles)
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CheckCSourceCompiles)
 
+find_package(SDL REQUIRED)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
 include_directories(${SDL_INCLUDE_DIR}) #hw
 include_directories(${LUA_INCLUDE_DIR}) #hw
 
-if(MACOSX)
+IF(MACOSX)
     # Fallback to older OS X on PowerPC to support wider range of systems...
-    if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
-        add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020)
-        set(OTHER_LDFLAGS ${OTHER_LDFLAGS} " -mmacosx-version-min=10.2")
-    endif(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
+    IF(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
+        ADD_DEFINITIONS(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020)
+        SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} " -mmacosx-version-min=10.2")
+    ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
 
     # Need these everywhere...
-    add_definitions(-fno-common)
-    set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit")
-endif(MACOSX)
+    ADD_DEFINITIONS(-fno-common)
+    SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit")
+ENDIF(MACOSX)
 
 # Add some gcc-specific command lines.
-if(CMAKE_COMPILER_IS_GNUCC)
+IF(CMAKE_COMPILER_IS_GNUCC)
     # Always build with debug symbols...you can strip it later.
-    add_definitions(-g -pipe -Werror -fsigned-char)
+    ADD_DEFINITIONS(-g -pipe -Werror -fsigned-char)
 
     # Stupid BeOS generates warnings in the system headers.
-    if(NOT BEOS)
-        add_definitions(-Wall)
-    endif(NOT BEOS)
+    IF(NOT BEOS)
+        ADD_DEFINITIONS(-Wall)
+    ENDIF(NOT BEOS)
 
     CHECK_C_SOURCE_COMPILES("
         #if ((defined(__GNUC__)) && (__GNUC__ >= 4))
@@ -68,31 +70,31 @@
         #endif
     " PHYSFS_IS_GCC4)
 
-    if(PHYSFS_IS_GCC4)
+    IF(PHYSFS_IS_GCC4)
         # Not supported on several operating systems at this time.
-        if(NOT SOLARIS AND NOT WINDOWS)
-            add_definitions(-fvisibility=hidden)
-        endif(NOT SOLARIS AND NOT WINDOWS)
-    endif(PHYSFS_IS_GCC4)
+        IF(NOT SOLARIS AND NOT WINDOWS)
+            ADD_DEFINITIONS(-fvisibility=hidden)
+        ENDIF(NOT SOLARIS AND NOT WINDOWS)
+    ENDIF(PHYSFS_IS_GCC4)
 
     # Don't use -rpath.
-    set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
-endif(CMAKE_COMPILER_IS_GNUCC)
+    SET(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
+ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
-if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
-    add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
-    add_definitions(-xldscope=hidden)
-endif(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
+IF(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
+    ADD_DEFINITIONS(-erroff=E_EMPTY_TRANSLATION_UNIT)
+    ADD_DEFINITIONS(-xldscope=hidden)
+ENDIF(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
 
-if(MSVC)
+IF(MSVC)
     # VS.NET 8.0 got really really anal about strcpy, etc, which even if we
     #  cleaned up our code, zlib, etc still use...so disable the warning.
-    add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
-endif(MSVC)
+    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1)
+ENDIF(MSVC)
 
 # Basic chunks of source code ...
 
-set(LZMA_SRCS
+SET(LZMA_SRCS
     src/lzma/C/7zCrc.c
     src/lzma/C/Archive/7z/7zBuffer.c
     src/lzma/C/Archive/7z/7zDecode.c
@@ -106,20 +108,20 @@
     src/lzma/C/Compress/Lzma/LzmaDecode.c
 )
 
-if(BEOS)
+IF(BEOS)
     # We add this explicitly, since we don't want CMake to think this
     #  is a C++ project unless we're on BeOS.
-    set(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
-    find_library(BE_LIBRARY be)
-    find_library(ROOT_LIBRARY root)
-    set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
-endif(BEOS)
+    SET(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
+    FIND_LIBRARY(BE_LIBRARY be)
+    FIND_LIBRARY(ROOT_LIBRARY root)
+    SET(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
+ENDIF(BEOS)
 
 # Almost everything is "compiled" here, but things that don't apply to the
 #  build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
 #  another project or bring up a new build system: just compile all the source
 #  code and #define the things you want.
-set(PHYSFS_SRCS
+SET(PHYSFS_SRCS
     src/physfs.c
     src/physfs_byteorder.c
     src/physfs_unicode.c
@@ -148,23 +150,23 @@
 
 # platform layers ...
 
-if(UNIX)
-    if(BEOS)
-        set(PHYSFS_HAVE_CDROM_SUPPORT true)
-        set(PHYSFS_HAVE_THREAD_SUPPORT true)
-        set(HAVE_PTHREAD_H true)
-    else(BEOS)
+IF(UNIX)
+    IF(BEOS)
+        SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+        SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
+        SET(HAVE_PTHREAD_H TRUE)
+    ELSE(BEOS)
         CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H)
-        if(HAVE_UCRED_H)
-            add_definitions(-DPHYSFS_HAVE_SYS_UCRED_H=1)
-            set(PHYSFS_HAVE_CDROM_SUPPORT false)
-        endif(HAVE_UCRED_H)
+        IF(HAVE_UCRED_H)
+            ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_UCRED_H=1)
+            SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+        ENDIF(HAVE_UCRED_H)
 
         CHECK_INCLUDE_FILE(mntent.h HAVE_MNTENT_H)
-        if(HAVE_MNTENT_H)
-            add_definitions(-DPHYSFS_HAVE_MNTENT_H=1)
-            set(PHYSFS_HAVE_CDROM_SUPPORT false)
-        endif(HAVE_MNTENT_H)
+        IF(HAVE_MNTENT_H)
+            ADD_DEFINITIONS(-DPHYSFS_HAVE_MNTENT_H=1)
+            SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+        ENDIF(HAVE_MNTENT_H)
 
         # !!! FIXME: Solaris fails this, because mnttab.h implicitly
         # !!! FIXME:  depends on other system headers.  :(
@@ -175,150 +177,149 @@
             int main(int argc, char **argv) { return 0; }
         " HAVE_SYS_MNTTAB_H)
 
-        if(HAVE_SYS_MNTTAB_H)
-            add_definitions(-DPHYSFS_HAVE_SYS_MNTTAB_H=1)
-            set(PHYSFS_HAVE_CDROM_SUPPORT false)
-        endif(HAVE_SYS_MNTTAB_H)
+        IF(HAVE_SYS_MNTTAB_H)
+            ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_MNTTAB_H=1)
+            SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+        ENDIF(HAVE_SYS_MNTTAB_H)
 
         CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
-        if(HAVE_PTHREAD_H)
-            set(PHYSFS_HAVE_THREAD_SUPPORT false)
-        endif(HAVE_PTHREAD_H)
-    endif(BEOS)
-endif(UNIX)
+        IF(HAVE_PTHREAD_H)
+            SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
+        ENDIF(HAVE_PTHREAD_H)
+    ENDIF(BEOS)
+ENDIF(UNIX)
 
-if(WINDOWS)
-    set(PHYSFS_HAVE_CDROM_SUPPORT true)
-    set(PHYSFS_HAVE_THREAD_SUPPORT true)
-endif(WINDOWS)
+IF(WINDOWS)
+    SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+    SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
+ENDIF(WINDOWS)
 
-if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
-    add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1)
-    message(WARNING " ***")
-    message(WARNING " *** There is no CD-ROM support in this build!")
-    message(WARNING " *** PhysicsFS will just pretend there are no discs.")
-    message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
-    message(WARNING " ***   but is this what you REALLY wanted?")
-    message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
-    message(WARNING " ***")
-endif(NOT PHYSFS_HAVE_CDROM_SUPPORT)
+IF(NOT PHYSFS_HAVE_CDROM_SUPPORT)
+    ADD_DEFINITIONS(-DPHYSFS_NO_CDROM_SUPPORT=1)
+    MESSAGE(WARNING " ***")
+    MESSAGE(WARNING " *** There is no CD-ROM support in this build!")
+    MESSAGE(WARNING " *** PhysicsFS will just pretend there are no discs.")
+    MESSAGE(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
+    MESSAGE(WARNING " ***   but is this what you REALLY wanted?")
+    MESSAGE(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
+    MESSAGE(WARNING " ***")
+ENDIF(NOT PHYSFS_HAVE_CDROM_SUPPORT)
 
-if(PHYSFS_HAVE_THREAD_SUPPORT)
-    add_definitions(-D_REENTRANT -D_THREAD_SAFE)
-else(PHYSFS_HAVE_THREAD_SUPPORT)
-    add_definitions(-DPHYSFS_NO_THREAD_SUPPORT=1)
-    message(WARNING " ***")
-    message(WARNING " *** There is no thread support in this build!")
-    message(WARNING " *** PhysicsFS will NOT be reentrant!")
-    message(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
-    message(WARNING " ***   but is this what you REALLY wanted?")
-    message(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
-    message(WARNING " ***")
-endif(PHYSFS_HAVE_THREAD_SUPPORT)
+IF(PHYSFS_HAVE_THREAD_SUPPORT)
+    ADD_DEFINITIONS(-D_REENTRANT -D_THREAD_SAFE)
+ELSE(PHYSFS_HAVE_THREAD_SUPPORT)
+    ADD_DEFINITIONS(-DPHYSFS_NO_THREAD_SUPPORT=1)
+    MESSAGE(WARNING " ***")
+    MESSAGE(WARNING " *** There is no thread support in this build!")
+    MESSAGE(WARNING " *** PhysicsFS will NOT be reentrant!")
+    MESSAGE(WARNING " *** This may be fine, depending on how PhysicsFS is used,")
+    MESSAGE(WARNING " ***   but is this what you REALLY wanted?")
+    MESSAGE(WARNING " *** (Maybe fix CMakeLists.txt, or write a platform driver?)")
+    MESSAGE(WARNING " ***")
+ENDIF(PHYSFS_HAVE_THREAD_SUPPORT)
 
 
 # Archivers ...
 
-option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" true)
-if(PHYSFS_ARCHIVE_ZIP)
-    add_definitions(-DPHYSFS_SUPPORTS_ZIP=1)
-endif(PHYSFS_ARCHIVE_ZIP)
+OPTION(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
+IF(PHYSFS_ARCHIVE_ZIP)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_ZIP=1)
+ENDIF(PHYSFS_ARCHIVE_ZIP)
 
-option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" false)
-if(PHYSFS_ARCHIVE_7Z)
-    add_definitions(-DPHYSFS_SUPPORTS_7Z=1)
+OPTION(PHYSFS_ARCHIVE_7Z "Enable 7zip support" FALSE)
+IF(PHYSFS_ARCHIVE_7Z)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_7Z=1)
     # !!! FIXME: rename to 7z.c?
-    set(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS})
-endif(PHYSFS_ARCHIVE_7Z)
+    SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS})
+ENDIF(PHYSFS_ARCHIVE_7Z)
 
-option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" true)
-if(PHYSFS_ARCHIVE_GRP)
-    add_definitions(-DPHYSFS_SUPPORTS_GRP=1)
-endif(PHYSFS_ARCHIVE_GRP)
+OPTION(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
+IF(PHYSFS_ARCHIVE_GRP)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_GRP=1)
+ENDIF(PHYSFS_ARCHIVE_GRP)
 
-option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" true)
-if(PHYSFS_ARCHIVE_WAD)
-    add_definitions(-DPHYSFS_SUPPORTS_WAD=1)
-endif(PHYSFS_ARCHIVE_WAD)
+OPTION(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
+IF(PHYSFS_ARCHIVE_WAD)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_WAD=1)
+ENDIF(PHYSFS_ARCHIVE_WAD)
 
-option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" true)
-if(PHYSFS_ARCHIVE_HOG)
-    add_definitions(-DPHYSFS_SUPPORTS_HOG=1)
-endif(PHYSFS_ARCHIVE_HOG)
+OPTION(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
+IF(PHYSFS_ARCHIVE_HOG)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_HOG=1)
+ENDIF(PHYSFS_ARCHIVE_HOG)
 
-option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" true)
-if(PHYSFS_ARCHIVE_MVL)
-    add_definitions(-DPHYSFS_SUPPORTS_MVL=1)
-endif(PHYSFS_ARCHIVE_MVL)
+OPTION(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
+IF(PHYSFS_ARCHIVE_MVL)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_MVL=1)
+ENDIF(PHYSFS_ARCHIVE_MVL)
 
-option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" true)
-if(PHYSFS_ARCHIVE_QPAK)
-    add_definitions(-DPHYSFS_SUPPORTS_QPAK=1)
-endif(PHYSFS_ARCHIVE_QPAK)
+OPTION(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
+IF(PHYSFS_ARCHIVE_QPAK)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_QPAK=1)
+ENDIF(PHYSFS_ARCHIVE_QPAK)
 
-option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" true)
-if(PHYSFS_ARCHIVE_ISO9660)
-    add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
-endif(PHYSFS_ARCHIVE_ISO9660)
+OPTION(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
+IF(PHYSFS_ARCHIVE_ISO9660)
+    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_ISO9660=1)
+ENDIF(PHYSFS_ARCHIVE_ISO9660)
 
 #as needed by Hedgewars configuration
-if(WINDOWS)
-    option(PHYSFS_BUILD_STATIC "Build static library" false)
-    option(PHYSFS_BUILD_SHARED "Build shared library" true)
-    set(OTHER_LDFLAGS ${OTHER_LDFLAGS} ${SDL_LIBRARY})
-else(WINDOWS)
-    option(PHYSFS_BUILD_STATIC "Build static library" true)
-    option(PHYSFS_BUILD_SHARED "Build shared library" false)
-endif(WINDOWS)
-
-if(PHYSFS_BUILD_STATIC)
-    add_library(physfs STATIC ${PHYSFS_SRCS})
-    set_target_properties(physfs PROPERTIES OUTPUT_NAME "physfs")
-    set(PHYSFS_LIB_TARGET physfs)
-    set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
-endif(PHYSFS_BUILD_STATIC)
+IF(WINDOWS)
+    OPTION(PHYSFS_BUILD_STATIC "Build static library" FALSE)
+    OPTION(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
+    SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} ${SDL_LIBRARY})
+ELSE(WINDOWS)
+    OPTION(PHYSFS_BUILD_STATIC "Build static library" TRUE)
+    OPTION(PHYSFS_BUILD_SHARED "Build shared library" FALSE)
+ENDIF(WINDOWS)
 
-if(PHYSFS_BUILD_SHARED)
-    find_package(SDL REQUIRED)
-    add_library(physfs SHARED ${PHYSFS_SRCS})
-    set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
-    set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
-    target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
-    set(PHYSFS_LIB_TARGET physfs)
-    set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
-    install(TARGETS ${PHYSFS_INSTALL_TARGETS}
-            RUNTIME DESTINATION bin)
-endif(PHYSFS_BUILD_SHARED)
+IF(PHYSFS_BUILD_STATIC)
+    ADD_LIBRARY(physfs STATIC ${PHYSFS_SRCS})
+    SET_TARGET_PROPERTIES(physfs PROPERTIES OUTPUT_NAME "physfs")
+    SET(PHYSFS_LIB_TARGET physfs)
+    SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
+ENDIF(PHYSFS_BUILD_STATIC)
 
-if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
-    message(FATAL "Both shared and static libraries are disabled!")
-endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
+IF(PHYSFS_BUILD_SHARED)
+    ADD_LIBRARY(physfs SHARED ${PHYSFS_SRCS})
+    SET_TARGET_PROPERTIES(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
+    SET_TARGET_PROPERTIES(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
+    TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
+    SET(PHYSFS_LIB_TARGET physfs)
+    SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
+    INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
+            RUNTIME DESTINATION ${LIBRARY_OUTPUT_PATH})
+ENDIF(PHYSFS_BUILD_SHARED)
+
+IF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
+    MESSAGE(FATAL "Both shared and static libraries are disabled!")
+ENDIF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
 
 # CMake FAQ says I need this...
-if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
-    set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
-endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
+IF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
+    SET_TARGET_PROPERTIES(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ENDIF(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
 
-option(PHYSFS_BUILD_TEST "Build stdio test program." false)
-mark_as_advanced(PHYSFS_BUILD_TEST)
-if(PHYSFS_BUILD_TEST)
-    find_path(READLINE_H readline/readline.h)
-    find_path(HISTORY_H readline/history.h)
-    if(READLINE_H AND HISTORY_H)
-        find_library(CURSES_LIBRARY NAMES curses ncurses)
-        set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
-        find_library(READLINE_LIBRARY readline)
-        if(READLINE_LIBRARY)
-            set(HAVE_SYSTEM_READLINE true)
-            set(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
-            include_directories(${READLINE_H} ${HISTORY_H})
-            add_definitions(-DPHYSFS_HAVE_READLINE=1)
-        endif(READLINE_LIBRARY)
-    endif(READLINE_H AND HISTORY_H)
-    add_executable(test_physfs test/test_physfs.c)
-    target_link_libraries(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
-    set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
-endif(PHYSFS_BUILD_TEST)
+OPTION(PHYSFS_BUILD_TEST "Build stdio test program." FALSE)
+MARK_AS_ADVANCED(PHYSFS_BUILD_TEST)
+IF(PHYSFS_BUILD_TEST)
+    FIND_PATH(READLINE_H readline/readline.h)
+    FIND_PATH(HISTORY_H readline/history.h)
+    IF(READLINE_H AND HISTORY_H)
+        FIND_LIBRARY(CURSES_LIBRARY NAMES curses ncurses)
+        SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
+        FIND_LIBRARY(READLINE_LIBRARY readline)
+        IF(READLINE_LIBRARY)
+            SET(HAVE_SYSTEM_READLINE TRUE)
+            SET(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
+            INCLUDE_DIRECTORIES(${READLINE_H} ${HISTORY_H})
+            ADD_DEFINITIONS(-DPHYSFS_HAVE_READLINE=1)
+        ENDIF(READLINE_LIBRARY)
+    ENDIF(READLINE_H AND HISTORY_H)
+    ADD_EXECUTABLE(test_physfs test/test_physfs.c)
+    TARGET_LINK_LIBRARIES(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
+    SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
+ENDIF(PHYSFS_BUILD_TEST)
 
 
 # Scripting language bindings...
@@ -326,38 +327,38 @@
 #CMake's SWIG support is basically useless.
 #FIND_PACKAGE(SWIG)
 
-option(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." false)
-mark_as_advanced(PHYSFS_BUILD_SWIG)
+OPTION(PHYSFS_BUILD_SWIG "Build ${_LANG} bindings." FALSE)
+MARK_AS_ADVANCED(PHYSFS_BUILD_SWIG)
 
-find_program(SWIG swig DOC "Path to swig command line app: http://swig.org/")
-if(NOT SWIG)
-    message(STATUS "SWIG not found. You won't be able to build scripting language bindings.")
-else(NOT SWIG)
-    mark_as_advanced(SWIG)
-    if(DEFINED CMAKE_BUILD_TYPE)
-        if((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
-            if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-                set(SWIG_OPT_CFLAGS "-small")
-            else(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-                set(SWIG_OPT_CFLAGS "-O")
-            endif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-        endif((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
-    endif(DEFINED CMAKE_BUILD_TYPE)
+FIND_PROGRAM(SWIG swig DOC "Path to swig command line app: http://swig.org/")
+IF(NOT SWIG)
+    MESSAGE(STATUS "SWIG not found. You won't be able to build scripting language bindings.")
+ELSE(NOT SWIG)
+    MARK_AS_ADVANCED(SWIG)
+    IF(DEFINED CMAKE_BUILD_TYPE)
+        IF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
+            IF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
+                SET(SWIG_OPT_CFLAGS "-small")
+            ELSE(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
+                SET(SWIG_OPT_CFLAGS "-O")
+            ENDIF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
+        ENDIF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
+    ENDIF(DEFINED CMAKE_BUILD_TYPE)
 
-    set(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings")
+    SET(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings")
 
-    macro(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS)
-        string(TOUPPER "${_LANG}" _UPPERLANG)
-        string(TOLOWER "${_LANG}" _LOWERLANG)
-        set(_TARGET "physfs-${_LOWERLANG}")
-        set(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}")
+    MACRO(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS)
+        STRING(TOUPPER "${_LANG}" _UPPERLANG)
+        STRING(TOLOWER "${_LANG}" _LOWERLANG)
+        SET(_TARGET "physfs-${_LOWERLANG}")
+        SET(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}")
 
-        if(NOT EXISTS "${_TARGETDIR}")
-            file(MAKE_DIRECTORY "${_TARGETDIR}")
-        endif(NOT EXISTS "${_TARGETDIR}")
+        IF(NOT EXISTS "${_TARGETDIR}")
+            FILE(MAKE_DIRECTORY "${_TARGETDIR}")
+        ENDIF(NOT EXISTS "${_TARGETDIR}")
 
-        if(PHYSFS_BUILD_${_UPPERLANG})
-            add_custom_command(
+        IF(PHYSFS_BUILD_${_UPPERLANG})
+            ADD_CUSTOM_COMMAND(
                 OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS}
                 MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
                 COMMAND "${SWIG}"
@@ -365,66 +366,66 @@
                 COMMENT "Generating ${_LANG} bindings..."
             )
 
-            add_library(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c")
-            target_link_libraries(${_TARGET} ${PHYSFS_LIB_TARGET})
-            set_target_properties(${_TARGET} PROPERTIES
+            ADD_LIBRARY(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c")
+            TARGET_LINK_LIBRARIES(${_TARGET} ${PHYSFS_LIB_TARGET})
+            SET_TARGET_PROPERTIES(${_TARGET} PROPERTIES
                 COMPILE_FLAGS "${_EXTRACFLAGS}"
                 LINK_FLAGS "${_EXTRALDFLAGS}"
                 LIBRARY_OUTPUT_NAME "physfs"
                 LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}"
                 CLEAN_DIRECT_OUTPUT 1
             )
-            install(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}")
-            message(STATUS "${_LANG} bindings configured!")
-        else(PHYSFS_BUILD_${_UPPERLANG})
-            message(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.")
-        endif(PHYSFS_BUILD_${_UPPERLANG})
-    endmacro(CONFIGURE_SWIG_BINDING)
+            INSTALL(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}")
+            MESSAGE(STATUS "${_LANG} bindings configured!")
+        ELSE(PHYSFS_BUILD_${_UPPERLANG})
+            MESSAGE(STATUS "Couldn't figure out ${_LANG} configuration. Skipping ${_LANG} bindings.")
+        ENDIF(PHYSFS_BUILD_${_UPPERLANG})
+    ENDMACRO(CONFIGURE_SWIG_BINDING)
 
-    macro(ADD_SCRIPT_BINDING_OPTION _VAR _LANG _DEFVAL)
-        set(BUILDSWIGVAL ${_DEFVAL})
-        if(NOT PHYSFS_BUILD_SWIG)
-            set(BUILDSWIGVAL false)
-        endif(NOT PHYSFS_BUILD_SWIG)
-        option(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL})
-        mark_as_advanced(${_VAR})
-    endmacro(ADD_SCRIPT_BINDING_OPTION)
+    MACRO(ADD_SCRIPT_BINDING_OPTION _VAR _LANG _DEFVAL)
+        SET(BUILDSWIGVAL ${_DEFVAL})
+        IF(NOT PHYSFS_BUILD_SWIG)
+            SET(BUILDSWIGVAL FALSE)
+        ENDIF(NOT PHYSFS_BUILD_SWIG)
+        OPTION(${_VAR} "Build ${_LANG} bindings." ${BUILDSWIGVAL})
+        MARK_AS_ADVANCED(${_VAR})
+    ENDMACRO(ADD_SCRIPT_BINDING_OPTION)
 
-    ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" true)
-    ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" true)
-endif(NOT SWIG)
+    ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_PERL "Perl" TRUE)
+    ADD_SCRIPT_BINDING_OPTION(PHYSFS_BUILD_RUBY "Ruby" TRUE)
+ENDIF(NOT SWIG)
 
-if(PHYSFS_BUILD_PERL)
-    message(STATUS "Configuring Perl bindings...")
-    find_program(PERL perl DOC "Path to perl command line app: http://perl.org/")
-    if(NOT PERL)
-        message(STATUS "Perl not found. You won't be able to build perl bindings.")
-        set(PHYSFS_BUILD_PERL false)
-    endif(NOT PERL)
-    mark_as_advanced(PERL)
+IF(PHYSFS_BUILD_PERL)
+    MESSAGE(STATUS "Configuring Perl bindings...")
+    FIND_PROGRAM(PERL perl DOC "Path to perl command line app: http://perl.org/")
+    IF(NOT PERL)
+        MESSAGE(STATUS "Perl not found. You won't be able to build perl bindings.")
+        SET(PHYSFS_BUILD_PERL FALSE)
+    ENDIF(NOT PERL)
+    MARK_AS_ADVANCED(PERL)
 
-    macro(GET_PERL_CONFIG _KEY _VALUE)
-        if(PHYSFS_BUILD_PERL)
-            message(STATUS "Figuring out perl config value '${_KEY}' ...")
-            execute_process(
+    MACRO(GET_PERL_CONFIG _KEY _VALUE)
+        IF(PHYSFS_BUILD_PERL)
+            MESSAGE(STATUS "Figuring out perl config value '${_KEY}' ...")
+            EXECUTE_PROCESS(
                 COMMAND ${PERL} -w -e "use Config; print \$Config{${_KEY}};"
                 RESULT_VARIABLE GET_PERL_CONFIG_RC
                 OUTPUT_VARIABLE ${_VALUE}
             )
-            if(NOT GET_PERL_CONFIG_RC EQUAL 0)
-                message(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}")
-                set(PHYSFS_BUILD_PERL false)
-            endif(NOT GET_PERL_CONFIG_RC EQUAL 0)
-            if(NOT ${_VALUE})
-                message(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'")
-                set(PHYSFS_BUILD_PERL false)
-            endif(NOT ${_VALUE})
+            IF(NOT GET_PERL_CONFIG_RC EQUAL 0)
+                MESSAGE(STATUS "Perl executable ('${PERL}') reported failure: ${GET_PERL_CONFIG_RC}")
+                SET(PHYSFS_BUILD_PERL FALSE)
+            ENDIF(NOT GET_PERL_CONFIG_RC EQUAL 0)
+            IF(NOT ${_VALUE})
+                MESSAGE(STATUS "Perl executable ('${PERL}') didn't have a value for '${_KEY}'")
+                SET(PHYSFS_BUILD_PERL FALSE)
+            ENDIF(NOT ${_VALUE})
 
-            if(PHYSFS_BUILD_PERL)
-                message(STATUS "Perl says: '${${_VALUE}}'.")
-            endif(PHYSFS_BUILD_PERL)
-        endif(PHYSFS_BUILD_PERL)
-    endmacro(GET_PERL_CONFIG)
+            IF(PHYSFS_BUILD_PERL)
+                MESSAGE(STATUS "Perl says: '${${_VALUE}}'.")
+            ENDIF(PHYSFS_BUILD_PERL)
+        ENDIF(PHYSFS_BUILD_PERL)
+    ENDMACRO(GET_PERL_CONFIG)
 
     # !!! FIXME: installsitearch might be the wrong location.
     GET_PERL_CONFIG("archlibexp" PERL_INCLUDE_PATH)
@@ -433,63 +434,63 @@
     GET_PERL_CONFIG("installsitearch" PERL_INSTALL_PATH)
 
     # !!! FIXME: this test for Mac OS X is wrong.
-    if(MACOSX)
+    IF(MACOSX)
         GET_PERL_CONFIG("libperl" PERL_LIBPERL)
-        set(TMPLIBPERL "${PERL_LIBPERL}")
-        string(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}")
-        string(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}")
-        string(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}")
-        string(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}")
-        if(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
-            message(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.")
-            set(PERL_LIBPERL "${TMPLIBPERL}")
-        endif(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
-        set(PERL_LIBPERL "-l${PERL_LIBPERL}")
-    endif(MACOSX)
+        SET(TMPLIBPERL "${PERL_LIBPERL}")
+        STRING(REGEX REPLACE "^lib" "" TMPLIBPERL "${TMPLIBPERL}")
+        STRING(REGEX REPLACE "\\.so$" "" TMPLIBPERL "${TMPLIBPERL}")
+        STRING(REGEX REPLACE "\\.dylib$" "" TMPLIBPERL "${TMPLIBPERL}")
+        STRING(REGEX REPLACE "\\.dll$" "" TMPLIBPERL "${TMPLIBPERL}")
+        IF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
+            MESSAGE(STATUS "Stripped '${PERL_LIBPERL}' down to '${TMPLIBPERL}'.")
+            SET(PERL_LIBPERL "${TMPLIBPERL}")
+        ENDIF(NOT "${TMPLIBPERL}" STREQUAL "${PERL_LIBPERL}")
+        SET(PERL_LIBPERL "-l${PERL_LIBPERL}")
+    ENDIF(MACOSX)
 
     CONFIGURE_SWIG_BINDING(Perl "${PERL_INSTALL_PATH}" "${SWIG_OUTPUT_DIR}/perl/physfs.pm" "\"-I${PERL_INCLUDE_PATH}/CORE\" ${PERL_CCFLAGS} -w" "\"-L${PERL_INCLUDE_PATH}/CORE\" ${PERL_LIBPERL} ${PERL_LDFLAGS}")
-    install(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
-    install(
+    INSTALL(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
+    INSTALL(
         FILES test/test_physfs.pl
         DESTINATION bin
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                     GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
     )
-endif(PHYSFS_BUILD_PERL)
+ENDIF(PHYSFS_BUILD_PERL)
 
 # !!! FIXME: lots of cut-and-paste from perl bindings.
-if(PHYSFS_BUILD_RUBY)
-    message(STATUS "Configuring Ruby bindings...")
-    find_program(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/")
-    if(NOT RUBY)
-        message(STATUS "Ruby not found. You won't be able to build ruby bindings.")
-        set(PHYSFS_BUILD_RUBY FALSE)
-    endif(NOT RUBY)
-    mark_as_advanced(RUBY)
+IF(PHYSFS_BUILD_RUBY)
+    MESSAGE(STATUS "Configuring Ruby bindings...")
+    FIND_PROGRAM(RUBY ruby DOC "Path to ruby command line app: http://ruby-lang.org/")
+    IF(NOT RUBY)
+        MESSAGE(STATUS "Ruby not found. You won't be able to build ruby bindings.")
+        SET(PHYSFS_BUILD_RUBY FALSE)
+    ENDIF(NOT RUBY)
+    MARK_AS_ADVANCED(RUBY)
 
-    macro(GET_RUBY_CONFIG _KEY _VALUE)
-        if(PHYSFS_BUILD_RUBY)
-            message(STATUS "Figuring out ruby config value '${_KEY}' ...")
-            execute_process(
+    MACRO(GET_RUBY_CONFIG _KEY _VALUE)
+        IF(PHYSFS_BUILD_RUBY)
+            MESSAGE(STATUS "Figuring out ruby config value '${_KEY}' ...")
+            EXECUTE_PROCESS(
                 COMMAND ${RUBY} -e "require 'rbconfig'; puts RbConfig::CONFIG['${_KEY}'];"
                 RESULT_VARIABLE GET_RUBY_CONFIG_RC
                 OUTPUT_VARIABLE ${_VALUE}
                 OUTPUT_STRIP_TRAILING_WHITESPACE
             )
-            if(NOT GET_RUBY_CONFIG_RC EQUAL 0)
-                message(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}")
-                set(PHYSFS_BUILD_RUBY FALSE)
-            endif(NOT GET_RUBY_CONFIG_RC EQUAL 0)
-            if(NOT ${_VALUE})
-                message(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'")
-                set(PHYSFS_BUILD_RUBY FALSE)
-            endif(NOT ${_VALUE})
+            IF(NOT GET_RUBY_CONFIG_RC EQUAL 0)
+                MESSAGE(STATUS "Ruby executable ('${RUBY}') reported failure: ${GET_RUBY_CONFIG_RC}")
+                SET(PHYSFS_BUILD_RUBY FALSE)
+            ENDIF(NOT GET_RUBY_CONFIG_RC EQUAL 0)
+            IF(NOT ${_VALUE})
+                MESSAGE(STATUS "Ruby executable ('${RUBY}') didn't have a value for '${_KEY}'")
+                SET(PHYSFS_BUILD_RUBY FALSE)
+            ENDIF(NOT ${_VALUE})
 
-            if(PHYSFS_BUILD_RUBY)
-                message(STATUS "Ruby says: '${${_VALUE}}'.")
-            endif(PHYSFS_BUILD_RUBY)
-        endif(PHYSFS_BUILD_RUBY)
-    endmacro(GET_RUBY_CONFIG)
+            IF(PHYSFS_BUILD_RUBY)
+                MESSAGE(STATUS "Ruby says: '${${_VALUE}}'.")
+            ENDIF(PHYSFS_BUILD_RUBY)
+        ENDIF(PHYSFS_BUILD_RUBY)
+    ENDMACRO(GET_RUBY_CONFIG)
 
     GET_RUBY_CONFIG("archdir" RUBY_INCLUDE_PATH)
     GET_RUBY_CONFIG("CFLAGS" RUBY_CCFLAGS)
@@ -499,14 +500,14 @@
     GET_RUBY_CONFIG("libdir" RUBY_LIBDIR)
 
     CONFIGURE_SWIG_BINDING(Ruby "${RUBY_INSTALL_PATH}" "" "\"-I${RUBY_INCLUDE_PATH}\" ${RUBY_CCFLAGS} -w" "\"-L${RUBY_LIBDIR}\" ${RUBY_LIBRUBY} ${RUBY_LDFLAGS}")
-    set_target_properties(physfs-ruby PROPERTIES PREFIX "")
-    install(
+    SET_TARGET_PROPERTIES(physfs-ruby PROPERTIES PREFIX "")
+    INSTALL(
         FILES test/test_physfs.rb
         DESTINATION bin
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                     GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
     )
-endif(PHYSFS_BUILD_RUBY)
+ENDIF(PHYSFS_BUILD_RUBY)
 
 
 #INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS}
@@ -515,9 +516,9 @@
 #        ARCHIVE DESTINATION lib${LIB_SUFFIX})
 #INSTALL(FILES src/physfs.h DESTINATION include)
 
-if(UNIX)
-    set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz")
-    add_custom_target(
+IF(UNIX)
+    SET(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.gz")
+    ADD_CUSTOM_TARGET(
         dist
         hg archive -t tgz "${PHYSFS_TARBALL}"
         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -529,17 +530,17 @@
 #        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
 #        COMMENT "Uninstall the project..."
 #    )
-endif(UNIX)
+ENDIF(UNIX)
 
-macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
-    if(${_VALUE})
-        message(STATUS "  ${_NAME}: enabled")
-    else(${_VALUE})
-        message(STATUS "  ${_NAME}: disabled")
-    endif(${_VALUE})
-endmacro(MESSAGE_BOOL_OPTION)
+MACRO(MESSAGE_BOOL_OPTION _NAME _VALUE)
+    IF(${_VALUE})
+        MESSAGE(STATUS "  ${_NAME}: enabled")
+    ELSE(${_VALUE})
+        MESSAGE(STATUS "  ${_NAME}: disabled")
+    ENDIF(${_VALUE})
+ENDMACRO(MESSAGE_BOOL_OPTION)
 
-message(STATUS "PhysicsFS will build with the following options:")
+MESSAGE(STATUS "PhysicsFS will build with the following options:")
 MESSAGE_BOOL_OPTION("ZIP support" PHYSFS_ARCHIVE_ZIP)
 MESSAGE_BOOL_OPTION("7zip support" PHYSFS_ARCHIVE_7Z)
 MESSAGE_BOOL_OPTION("GRP support" PHYSFS_ARCHIVE_GRP)
@@ -554,9 +555,9 @@
 MESSAGE_BOOL_OPTION("Build Perl bindings" PHYSFS_BUILD_PERL)
 MESSAGE_BOOL_OPTION("Build Ruby bindings" PHYSFS_BUILD_RUBY)
 MESSAGE_BOOL_OPTION("Build stdio test program" PHYSFS_BUILD_TEST)
-if(PHYSFS_BUILD_TEST)
+IF(PHYSFS_BUILD_TEST)
     MESSAGE_BOOL_OPTION("  Use readline in test program" HAVE_SYSTEM_READLINE)
-endif(PHYSFS_BUILD_TEST)
+ENDIF(PHYSFS_BUILD_TEST)
 
 # end of CMakeLists.txt ...
 
--- a/share/CMakeLists.txt	Sun Dec 16 12:05:32 2012 +0400
+++ b/share/CMakeLists.txt	Sun Dec 16 12:25:13 2012 +0400
@@ -9,6 +9,15 @@
         set(HEDGEWARS_REVISION ${HEDGEWARS_VERSION})
     endif()
 
+    #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
+    if(NOT NOVIDEOREC)
+        set(FFMPEG_FIND_QUIETLY true)
+        find_package(FFMPEG)
+        if(${FFMPEG_FOUND} AND ${minimum_macosx_version} VERSION_EQUAL "10.6")
+            set(minimum_macosx_version "10.6.3")
+        endif()
+    endif()
+
     configure_file(${hedgewars_SOURCE_DIR}/share/Info.plist.in
                    ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
     #path here should be Hedgewars.app/Contents/MacOS