merge cmake osx sdk changes
authorkoda
Fri, 03 Jan 2014 01:41:32 +0100
changeset 9912 fa93fbd543b4
parent 9910 b0988e40e411 (diff)
parent 9889 54b49e8d8bfa (current diff)
child 9914 ba26595503ab
child 9915 67c9bd84f941
child 9918 ca90e470333b
merge cmake osx sdk changes
--- a/.hgtags	Fri Jan 03 01:40:50 2014 +0100
+++ b/.hgtags	Fri Jan 03 01:41:32 2014 +0100
@@ -60,3 +60,4 @@
 0000000000000000000000000000000000000000 0.9.18-release
 2fc02902c7cbf3c29bfe08a50e5f37983582b251 0.9.18-release
 1617149e01a4fa25637e2ab655d0287ef9c21b7c 0.9.19-release
+af0520a6bf0061b27f8321514d35fcd2b1ef5f9c 0.9.20-release
--- a/CMakeLists.txt	Fri Jan 03 01:40:50 2014 +0100
+++ b/CMakeLists.txt	Fri Jan 03 01:41:32 2014 +0100
@@ -43,7 +43,7 @@
 set(CPACK_PACKAGE_VERSION_MAJOR 0)
 set(CPACK_PACKAGE_VERSION_MINOR 9)
 set(CPACK_PACKAGE_VERSION_PATCH 20)
-set(HEDGEWARS_PROTO_VER 47)
+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)
 
--- a/QTfrontend/model/ammoSchemeModel.cpp	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/model/ammoSchemeModel.cpp	Fri Jan 03 01:41:32 2014 +0100
@@ -65,6 +65,7 @@
                                 << QVariant(100)           // rope modfier   39
                                 << QVariant(100)           // get away time  40
                                 << QVariant(0)             // world edge     41
+                                << QVariant()              // scriptparam    42
                                 ;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -130,6 +131,7 @@
               << "ropepct"             // 39
               << "getawaytime"         // 40
               << "worldedge"           // 41
+              << "scriptparam"         // scriptparam    42
               ;
 
     QList<QVariant> proMode;
@@ -176,6 +178,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> shoppa;
@@ -222,6 +225,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> cleanslate;
@@ -268,6 +272,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> minefield;
@@ -314,6 +319,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> barrelmayhem;
@@ -360,6 +366,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> tunnelhogs;
@@ -406,6 +413,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> forts;
@@ -452,6 +460,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> timeless;
@@ -498,6 +507,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> thinkingportals;
@@ -544,6 +554,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
     QList<QVariant> kingmode;
@@ -590,6 +601,7 @@
             << QVariant(100)           // rope modfier   39
             << QVariant(100)           // get away time  40
             << QVariant(0)             // world edge     41
+            << QVariant()              // scriptparam    42
             ;
 
 
@@ -793,6 +805,8 @@
         return;
     }
 
+    cfg[42] = cfg[42].mid(1);
+
     for(int i = 0; i < cfg.size(); ++i)
         netScheme[i] = QVariant(cfg[i]);
 
--- a/QTfrontend/net/newnetclient.cpp	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/net/newnetclient.cpp	Fri Jan 03 01:41:32 2014 +0100
@@ -545,7 +545,7 @@
         m_roomsListModel->updateRoom(roomName, tmp);
 
         // keep track of room name so correct name is displayed
-        if(myroom == roomName)
+        if(myroom == roomName && myroom != tmp[1])
         {
             myroom = tmp[1];
             emit roomNameUpdated(myroom);
--- a/QTfrontend/ui/page/pagescheme.cpp	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/ui/page/pagescheme.cpp	Fri Jan 03 01:41:32 2014 +0100
@@ -390,6 +390,7 @@
     l->setFixedSize(32,32);
     l->setPixmap(QPixmap(":/res/iconEarth.png"));
     glBSLayout->addWidget(l,15,1,1,1);
+
     CB_WorldEdge = new QComboBox(gbBasicSettings);
     CB_WorldEdge->insertItem(0, tr("None (Default)"));
     CB_WorldEdge->insertItem(1, tr("Wrap (World wraps)"));
@@ -400,6 +401,20 @@
 
 
     l = new QLabel(gbBasicSettings);
+    l->setText(QLabel::tr("Script parameter"));
+    l->setWordWrap(true);
+    glBSLayout->addWidget(l,16,0,1,1);
+    l = new QLabel(gbBasicSettings);
+    l->setFixedSize(32,32);
+    l->setPixmap(QPixmap(":/res/iconBox.png"));
+    glBSLayout->addWidget(l,16,1,1,1);
+
+    LE_ScriptParam = new QLineEdit(gbBasicSettings);
+    LE_ScriptParam->setMaxLength(240);
+    glBSLayout->addWidget(LE_ScriptParam,16,2,1,1);
+
+
+    l = new QLabel(gbBasicSettings);
     l->setText(QLabel::tr("Scheme Name:"));
 
     LE_name = new QLineEdit(this);
@@ -489,6 +504,7 @@
     mapper->addMapping(SB_RopeModifier, 39);
     mapper->addMapping(SB_GetAwayTime, 40);
     mapper->addMapping(CB_WorldEdge, 41, "currentIndex");
+    mapper->addMapping(LE_ScriptParam, 42);
 
     mapper->toFirst();
 }
--- a/QTfrontend/ui/page/pagescheme.h	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/ui/page/pagescheme.h	Fri Jan 03 01:41:32 2014 +0100
@@ -93,6 +93,7 @@
         QSpinBox * SB_GetAwayTime;
         QComboBox * CB_WorldEdge;
         QLineEdit * LE_name;
+        QLineEdit * LE_ScriptParam;
 
         QGroupBox * gbGameModes;
         QGroupBox * gbBasicSettings;
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Fri Jan 03 01:41:32 2014 +0100
@@ -324,7 +324,8 @@
     bcfg << QString("e$worldedge %1").arg(schemeData(41).toInt()).toUtf8();
     bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
     bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
-
+    if(!schemeData(42).isNull())
+        bcfg << QString("e$scriptparam %1").arg(schemeData(42).toString()).toUtf8();
 
 
     switch (mapgen)
@@ -569,7 +570,11 @@
     for(int i = 0; i < size; ++i)
         sl << schemeData(i).toString();
 
-    if (sl.size()!=1) emit paramChanged("SCHEME", sl);  // this is a stupid hack for the fact that SCHEME is being sent once, empty. Still need to find out why.
+    if (sl.size() >= 42)
+    {
+        sl[42].prepend('!');
+        emit paramChanged("SCHEME", sl);  // this is a stupid hack for the fact that SCHEME is being sent once, empty. Still need to find out why.
+    }
 
     if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked())
     {
--- a/QTfrontend/ui/widget/selectWeapon.cpp	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.cpp	Fri Jan 03 01:41:32 2014 +0100
@@ -93,7 +93,7 @@
     for(int i = 0; i < keys.size(); i++)
     {
         if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size())
-            wconf->remove(keys[i]);
+            wconf->setValue(keys[i], fixWeaponSet(wconf->value(keys[i]).toString()));
     }
 
     QString currentState = *cDefaultAmmoStore;
@@ -333,3 +333,22 @@
         setWeapons(ammo);
     }
 }
+
+QString SelWeaponWidget::fixWeaponSet(const QString &s)
+{
+    int neededLength = cDefaultAmmoStore->size() / 4;
+    int thisSetLength = s.size() / 4;
+
+    QStringList sl;
+    sl
+            << s.left(thisSetLength)
+            << s.mid(thisSetLength, thisSetLength)
+            << s.mid(thisSetLength * 2, thisSetLength)
+            << s.right(thisSetLength)
+               ;
+
+    for(int i = sl.length() - 1; i >= 0; --i)
+        sl[i] = sl[i].leftJustified(neededLength, '0', true);
+
+    return sl.join(QString());
+}
--- a/QTfrontend/ui/widget/selectWeapon.h	Fri Jan 03 01:40:50 2014 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.h	Fri Jan 03 01:41:32 2014 +0100
@@ -87,6 +87,8 @@
         QGridLayout* p2Layout;
         QGridLayout* p3Layout;
         QGridLayout* p4Layout;
+
+        QString fixWeaponSet(const QString & s);
 };
 
 #endif // _SELECT_WEAPON_INCLUDED
--- a/cmake_modules/cpackvars.cmake	Fri Jan 03 01:40:50 2014 +0100
+++ b/cmake_modules/cpackvars.cmake	Fri Jan 03 01:41:32 2014 +0100
@@ -89,6 +89,8 @@
 #    "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/cmdlineClient"
     "^${CMAKE_CURRENT_SOURCE_DIR}/misc/winutils/bin"
     "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/promotional_art"
+    "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/AudioMono"
+    "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/HedgewarsMobile"
     "^${CMAKE_CURRENT_SOURCE_DIR}/tools/templates"
     "^${CMAKE_CURRENT_SOURCE_DIR}/tools/drawMapTest"
     "^${CMAKE_CURRENT_SOURCE_DIR}/doc"
--- a/gameServer/CoreTypes.hs	Fri Jan 03 01:40:50 2014 +0100
+++ b/gameServer/CoreTypes.hs	Fri Jan 03 01:41:32 2014 +0100
@@ -253,7 +253,7 @@
         True
         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
         "<font color=yellow><h3 align=center>Hedgewars 0.9.19 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
-        45 -- latestReleaseVersion
+        47 -- latestReleaseVersion
         41 -- earliestCompatibleVersion
         46631
         ""
--- a/gameServer/OfficialServer/extdbinterface.hs	Fri Jan 03 01:40:50 2014 +0100
+++ b/gameServer/OfficialServer/extdbinterface.hs	Fri Jan 03 01:41:32 2014 +0100
@@ -11,6 +11,7 @@
 import Database.HDBC.MySQL
 import Data.List (lookup)
 import qualified Data.ByteString.Char8 as B
+import Data.Word
 --------------------------
 import CoreTypes
 import Utils
@@ -91,7 +92,7 @@
         , SqlInt32 (readInt_ value)
         , SqlByteString fileName
         , SqlByteString location
-        , SqlInt32 p
+        , SqlInt32 $ fromIntegral p
         ] : ps bs
     ps (b:bs) = ps bs
 
--- a/hedgewars/CMakeLists.txt	Fri Jan 03 01:40:50 2014 +0100
+++ b/hedgewars/CMakeLists.txt	Fri Jan 03 01:41:32 2014 +0100
@@ -4,7 +4,8 @@
 find_package(SDL_ttf)
 find_package(SDL_mixer)
 
-include (CheckLibraryExists)
+include(CheckLibraryExists)
+include(${CMAKE_MODULE_PATH}/utils.cmake)
 
 
 enable_language(Pascal)
@@ -83,16 +84,9 @@
 
     #these interact with everything, so compile last
     uScript.pas
-    hwengine.pas
-
-    #we also have uTouch.pas
-    options.inc
-    ${CMAKE_CURRENT_BINARY_DIR}/config.inc
     )
 
 
-include(${CMAKE_MODULE_PATH}/utils.cmake)
-
 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})!")
@@ -171,10 +165,9 @@
 add_definitions(-dDEBUGFILE)
 
 
-# make source files objects depend on their predecessors in list
+# source files are with full path after this
 set(sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/options.inc" "${CMAKE_CURRENT_BINARY_DIR}/config.inc")
 foreach(loop_var ${engine_sources})
-    SET_SOURCE_FILES_PROPERTIES(${loop_var} PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
     list(APPEND sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/${loop_var}")
 endforeach(loop_var)
 
@@ -193,12 +186,14 @@
     add_flag_prepend(CMAKE_Pascal_FLAGS "-o${LIBRARY_OUTPUT_PATH}/${engine_output_name}")
 
     add_definitions(-dHWLIBRARY)
-    add_library(hwengine SHARED ${engine_sources} hwLibrary.pas)
+    set_source_files_properties(hwLibrary.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
+    add_library(hwengine SHARED hwLibrary.pas)
 else()
     # no need to change name here because target has same name
     set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
     set(destination_dir ${target_binary_install_dir})
-    add_executable(hwengine ${engine_sources})
+    set_source_files_properties(hwengine.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
+    add_executable(hwengine hwengine.pas)
 endif()
 
 #even though not actually used, this will trigger relink if any lib changes
--- a/hedgewars/uCommandHandlers.pas	Fri Jan 03 01:40:50 2014 +0100
+++ b/hedgewars/uCommandHandlers.pas	Fri Jan 03 01:41:32 2014 +0100
@@ -119,6 +119,11 @@
 ScriptLoad(s)
 end;
 
+procedure chScriptParam(var s: shortstring);
+begin
+    cScriptParam:= s;
+end;
+
 procedure chCurU_p(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
@@ -796,6 +801,7 @@
 //////// End top by freq analysis
     RegisterVariable('gencmd'  , @chGenCmd       , false);
     RegisterVariable('script'  , @chScript       , false);
+    RegisterVariable('scriptparam', @chScriptParam, false);
     RegisterVariable('proto'   , @chCheckProto   , true );
     RegisterVariable('spectate', @chFastUntilLag   , false);
     RegisterVariable('capture' , @chCapture      , true );
--- a/hedgewars/uLand.pas	Fri Jan 03 01:40:50 2014 +0100
+++ b/hedgewars/uLand.pas	Fri Jan 03 01:41:32 2014 +0100
@@ -190,19 +190,22 @@
 procedure ColorizeLand(Surface: PSDL_Surface);
 var tmpsurf: PSDL_Surface;
     r: TSDL_Rect;
+    y: LongWord; // stupid SDL 1.2 uses stupid SmallInt for y which limits us to 32767.  But is even worse if LandTex is large, can overflow on 32767 map.
 begin
     tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps);
     r.y:= 0;
-    while r.y < LAND_HEIGHT do
-    begin
+    y:= 0;
+    while y < LAND_HEIGHT do
+        begin
         r.x:= 0;
         while r.x < LAND_WIDTH do
-        begin
+            begin
             SDL_UpperBlit(tmpsurf, nil, Surface, @r);
             inc(r.x, tmpsurf^.w)
+            end;
+        inc(y, tmpsurf^.h);
+        r.y:= y
         end;
-        inc(r.y, tmpsurf^.h)
-    end;
     SDL_FreeSurface(tmpsurf);
 
     // freed in freeModule() below
--- a/hedgewars/uScript.pas	Fri Jan 03 01:40:50 2014 +0100
+++ b/hedgewars/uScript.pas	Fri Jan 03 01:41:32 2014 +0100
@@ -2042,9 +2042,9 @@
 ScriptSetInteger('HealthDecrease', cHealthDecrease);
 ScriptSetInteger('GetAwayTime', cGetAwayTime);
 ScriptSetString('Map', cMapName);
-
 ScriptSetString('Theme', '');
 ScriptSetString('Goals', '');
+ScriptSetString('ScriptParam', cScriptParam);
 
 ScriptCall('onGameInit');
 
@@ -2444,7 +2444,6 @@
 ScriptSetInteger('gmPrecise', gmPrecise);
 ScriptSetInteger('gmAllStoppable', gmAllStoppable);
 
-
 // speech bubbles
 ScriptSetInteger('SAY_SAY', 1);
 ScriptSetInteger('SAY_THINK', 2);
--- a/hedgewars/uVariables.pas	Fri Jan 03 01:40:50 2014 +0100
+++ b/hedgewars/uVariables.pas	Fri Jan 03 01:41:32 2014 +0100
@@ -147,6 +147,7 @@
     cExplosives     : Longword;
 
     cScriptName     : shortstring;
+    cScriptParam    : shortstring;
     cSeed           : shortstring;
     cVolumeDelta    : LongInt;
     cHasFocus       : boolean;
@@ -2551,6 +2552,7 @@
     fastScrolling   := false;
     autoCameraOn    := true;
     cScriptName     := '';
+    cScriptParam    := '';
     cSeed           := '';
     cVolumeDelta    := 0;
     cHasFocus       := true;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Fri Jan 03 01:40:50 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Fri Jan 03 01:41:32 2014 +0100
@@ -1,8 +1,15 @@
 HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/Params.lua")
 
 local gravity = 100
+local mingravity
+local maxgravity
+local delta = 0
+local period
+local periodtimer = 0
 local wdGameTicks = 0
 local wdTTL = 0
+local mln = 1000000
 
 function onNewTurn()
     SetGravity(gravity)
@@ -10,24 +17,90 @@
 end
 
 function onGameTick20()
-    if (TurnTimeLeft < 20) or (TurnTimeLeft > 0 and wdGameTicks + 15000 < GameTime) then
+    if wdGameTicks + 15000 < GameTime then
         SetGravity(100)
-    elseif wdTTL ~= TurnTimeLeft then
-        wdGameTicks = GameTime
-        SetGravity(gravity)
+    else
+        if wdTTL ~= TurnTimeLeft then
+            wdGameTicks = GameTime
+        end
+
+        if delta == nil then
+            if periodtimer == 0 then
+                periodtimer = period * 2
+                SetGravity(div(GetRandom(maxgravity - mingravity) + mingravity, mln))
+            else
+                periodtimer = periodtimer - 1
+            end
+        elseif delta == 0 then
+            SetGravity(gravity)
+        else
+            if delta > 0 and gravity + delta > maxgravity then
+                gravity = maxgravity
+                delta = -delta
+            elseif delta < 0 and gravity - delta < mingravity then
+                gravity = mingravity
+                delta = -delta
+            else
+                gravity = gravity + delta
+            end
+
+            SetGravity(div(gravity, mln))
+        end
     end
 
     wdTTL = TurnTimeLeft
 end
 
 function onGameInit()
-    gravity = GetAwayTime
-    GetAwayTime = 100
+    parseParams()
+
+    gravity = params["g"]
+
+    mingravity = gravity
+    maxgravity = params["g2"]
+    period = params["period"]
+
+    if mingravity ~= nil and maxgravity ~= nil then
+        if period ~= nil then
+            period = div(period, 40)
+        else
+            period = 125
+        end
+
+        if mingravity > maxgravity then
+            mingravity, maxgravity = maxgravity, mingravity
+        end
+
+        mingravity = mingravity * mln
+        maxgravity = maxgravity * mln
+        gravity = mingravity
+
+        if period > 0 then
+            delta = div(maxgravity - mingravity, period)
+        else
+            period = -period
+            delta = nil
+        end
+    end
+
+    if gravity == nil then
+        gravity = 100
+    end
 end
 
 function 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
+        v = string.format(loc("changing range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40)
+    else
+        v = gravity .. "%"
+    end
+
     ShowMission(loc("Gravity"),
-                loc("Current value is ") .. gravity .. "%",
-                loc("Set any gravity value you want by adjusting get away time"),
+                loc("Current setting is ") .. v,
+                loc("Setup:|'g=150', where 150 is 150% of normal gravity") .. "|"
+                .. 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)
-end
\ No newline at end of file
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/Params.lua	Fri Jan 03 01:41:32 2014 +0100
@@ -0,0 +1,9 @@
+-- Library for parameters handling
+
+params = {}
+
+function parseParams()
+    for k, v in string.gmatch(ScriptParam, "(%w+)=([^,]+)") do
+        params[k] = v
+    end
+end