fix a few loose ends here webgl
authorkoda
Tue, 18 Jun 2013 09:48:10 +0200
branchwebgl
changeset 9244 bb95e351270c
parent 9242 c07f341adad9
child 9246 75f430ebeb74
fix a few loose ends here
CMakeLists.txt
QTfrontend/CMakeLists.txt
cmake_modules/FindGLEW.cmake
cmake_modules/utils.cmake
hedgewars/CMakeLists.txt
hedgewars/uScript.pas
hedgewars/uTypes.pas
project_files/hwc/rtl/typinfo.h
--- a/CMakeLists.txt	Mon Jun 17 23:24:18 2013 +0200
+++ b/CMakeLists.txt	Tue Jun 18 09:48:10 2013 +0200
@@ -104,7 +104,7 @@
     if(${allow_parse_args})
         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
     else()
-        message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
+        message("*** FPFLAGS and GHFLAGS are available only when using CMake >= 2.8 ***")
     endif()
 endif()
 
@@ -124,6 +124,7 @@
     list(APPEND haskell_flags "-Wall"       # all warnings
                               "-debug"      # debug mode
                               "-dcore-lint" # internal sanity check
+                              "-fno-warn-unused-do-bind"
                               )
 else()
     list(APPEND haskell_flags "-w" # no warnings
@@ -136,7 +137,7 @@
     find_package(Clang)
     # Check LLVM/Clang version
     if(CLANG_VERSION VERSION_LESS required_clang_version)
-	message(FATAL_ERROR "LLVM/Clang compiler required version is ${required_clang_version} but version ${CLANG_VERSION} was found!")
+        message(FATAL_ERROR "LLVM/Clang compiler required version is ${required_clang_version} but version ${CLANG_VERSION} was found!")
     else()
         message(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
     endif()
@@ -214,9 +215,12 @@
 #physfs helper library
 add_subdirectory(misc/libphyslayer)
 
+if(NOT BUILD_ENGINE_LIBRARY AND APPLE)
+    add_subdirectory(hedgewars/sdlmain)
+endif()
+
 #TODO: nowadays this could be merged inside hedgewars/CMakeLists.txt
 if(NOPASCAL)
-    add_subdirectory(hedgewars/sdlmain)
     #pascal to c converter
     add_subdirectory(tools/pas2c)
     add_subdirectory(project_files/hwc)
@@ -229,7 +233,7 @@
     #WEBGL deps
 else(WEBGL)
     #Android related build scripts
-    #TODO: when ANDROID, LIBENGINE should be set
+    #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
     if(ANDROID)
         add_subdirectory(project_files/Android-build)
     else(ANDROID)
--- a/QTfrontend/CMakeLists.txt	Mon Jun 17 23:24:18 2013 +0200
+++ b/QTfrontend/CMakeLists.txt	Tue Jun 18 09:48:10 2013 +0200
@@ -146,11 +146,6 @@
 
 set(hwfr_rez hedgewars.qrc)
 
-if(${BUILD_ENGINE_LIBRARY})
-    add_definitions(-DHWLIBRARY=1)
-    set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
-    list(APPEND HW_LINK_LIBS ${hwlibname})
-endif()
 
 qt4_add_resources(hwfr_rez_src ${hwfr_rez})
 
@@ -181,10 +176,10 @@
 if(CMAKE_BUILD_TYPE MATCHES "RELEASE")
     set(console_access "WIN32")
 endif(CMAKE_BUILD_TYPE MATCHES "RELEASE")
-if(${LIBENGINE})
-    add_definitions(-DHWLIBRARY)
-    set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS})
-    link_directories(${EXECUTABLE_OUTPUT_PATH})
+if(${BUILD_ENGINE_LIBRARY})
+    add_definitions(-DHWLIBRARY=1)
+    set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
+    list(APPEND HW_LINK_LIBS ${hwlibname})
 endif()
 
 add_executable(hedgewars ${console_access}
--- a/cmake_modules/FindGLEW.cmake	Mon Jun 17 23:24:18 2013 +0200
+++ b/cmake_modules/FindGLEW.cmake	Tue Jun 18 09:48:10 2013 +0200
@@ -34,6 +34,6 @@
             $ENV{PROGRAMFILES}/GLEW/lib
             DOC "The GLEW library")
 
-find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIR GLEW_LIBRARY)
-mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
+find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_DIR)
+mark_as_advanced(GLEW_LIBRARY GLEW_INCLUDE_DIR)
 
--- a/cmake_modules/utils.cmake	Mon Jun 17 23:24:18 2013 +0200
+++ b/cmake_modules/utils.cmake	Tue Jun 18 09:48:10 2013 +0200
@@ -36,7 +36,7 @@
 endmacro(add_flag_prepend _VAR_NAME _FLAG)
 
 macro(add_linker_flag _FLAG)
-    list(APPEND haskell_flags "-optl" "${_FLAG}")
+    list(APPEND haskell_flags "-optl" "-Wl,${_FLAG}")
     add_flag_append(CMAKE_Pascal_FLAGS "-k${_FLAG}")
     add_flag_append(CMAKE_EXE_LINKER_FLAGS "-Wl,${_FLAG}")
     add_flag_append(CMAKE_SHARED_LIBRARY_C_FLAGS "-Wl,${_FLAG}")
--- a/hedgewars/CMakeLists.txt	Mon Jun 17 23:24:18 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Tue Jun 18 09:48:10 2013 +0200
@@ -116,7 +116,7 @@
         endif()
         list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs)
         if(num_of_archs GREATER 1)
-            message(${WARNING} "Only one architecture in CMAKE_OSX_ARCHITECTURES is currently supported, picking the first one")
+            message("*** Only one architecture in CMAKE_OSX_ARCHITECTURES is currently supported, picking the first one ***")
         endif()
     elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
         #if that variable is not set check if we are on x86_64 and if so force it, else use default
@@ -125,7 +125,6 @@
 
     #on OSX we need to provide the SDL_main() function when building as executable
     if(NOT BUILD_ENGINE_LIBRARY)
-        add_subdirectory(sdlmain)
         list(APPEND HW_LINK_LIBS SDLmain)
         add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
     endif()
--- a/hedgewars/uScript.pas	Mon Jun 17 23:24:18 2013 +0200
+++ b/hedgewars/uScript.pas	Tue Jun 18 09:48:10 2013 +0200
@@ -84,8 +84,7 @@
     SDLh,
     SysUtils,
     uIO,
-    uPhysFSLayer,
-    typinfo
+    uPhysFSLayer
     ;
 
 var luaState : Plua_State;
@@ -1292,49 +1291,49 @@
 var i : LongInt;
 var color : shortstring;
 begin
-	statInfo := TStatInfoType(lua_tostring(L, 1));
-	if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) 
-			and (statInfo <> siClanHealth)) then
+    statInfo := TStatInfoType(lua_tointeger(L, 1));
+    if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills)
+            and (statInfo <> siClanHealth)) then
         begin
         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.');
         end
-    else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) 
-			or (statInfo = siClanHealth)) then
-		begin
+    else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills)
+            or (statInfo = siClanHealth)) then
+        begin
         LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.');
         end
     else
-		begin
-		if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then
-			begin
-			// 3: team name
-			for i:= 0 to Pred(TeamsCount) do
-				begin
-				with TeamsArray[i]^ do
-					begin
-						if TeamName = lua_tostring(L, 3) then
-							begin
-							color := uUtils.IntToStr(Clan^.Color);
-							Break;
-							end
-					end				
-				end;
-			if (statInfo = siPlayerKills) then
-				begin
-					SendStat(siPlayerKills, color + ' ' +
-						lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName);
-				end
-			else if (statInfo = siClanHealth) then
-				begin
-					SendStat(siClanHealth, color + ' ' +
-						lua_tostring(L, 2));
-				end
-			end
-		else
-			begin
-			SendStat(statInfo,lua_tostring(L, 2));
-			end;
-		end;
+        begin
+        if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then
+            begin
+            // 3: team name
+            for i:= 0 to Pred(TeamsCount) do
+                begin
+                with TeamsArray[i]^ do
+                    begin
+                        if TeamName = lua_tostring(L, 3) then
+                            begin
+                            color := uUtils.IntToStr(Clan^.Color);
+                            Break;
+                            end
+                    end
+                end;
+            if (statInfo = siPlayerKills) then
+                begin
+                    SendStat(siPlayerKills, color + ' ' +
+                        lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName);
+                end
+            else if (statInfo = siClanHealth) then
+                begin
+                    SendStat(siClanHealth, color + ' ' +
+                        lua_tostring(L, 2));
+                end
+            end
+        else
+            begin
+            SendStat(statInfo,lua_tostring(L, 2));
+            end;
+        end;
     lc_sendstat:= 0
 end;
 
--- a/hedgewars/uTypes.pas	Mon Jun 17 23:24:18 2013 +0200
+++ b/hedgewars/uTypes.pas	Tue Jun 18 09:48:10 2013 +0200
@@ -43,9 +43,9 @@
 
     // Different files are stored in different folders, this enumeration is used to tell which folder to use
     TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps,
-            ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts,
-            ptLocale, ptAmmoMenu, ptHedgehog, ptVoices, ptHats, ptFlags, ptMissionMaps, ptSuddenDeath, ptButtons,
-            ptShaders);
+            ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts, ptLocale,
+            ptAmmoMenu, ptHedgehog, ptVoices, ptHats, ptFlags, ptMissionMaps,
+            ptSuddenDeath, ptButtons, ptShaders);
 
     // Available sprites for displaying stuff
     TSprite = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
@@ -87,11 +87,12 @@
             sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
             sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
             sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
-            sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog
+            sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun,
+            sprFrozenHog
             );
 
     // Gears that interact with other Gears and/or Land
-    TGearType = ({-->}gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // <-- these are gears which should be avoided when searching a spawn place
+    TGearType = (gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // these gears should be avoided when searching a spawn place
             gtGrenade, gtShell, gtGrave, gtBee, // 8
             gtShotgunShot, gtPickHammer, gtRope,  // 11
             gtDEagleShot, gtDynamite, gtClusterBomb, gtCluster, gtShover, // 16
@@ -139,9 +140,10 @@
             sndHellishImpact1, sndHellishImpact2, sndHellishImpact3, sndHellishImpact4,
             sndMelonImpact, sndDroplet1, sndDroplet2, sndDroplet3, sndEggBreak, sndDrillRocket,
             sndPoisonCough, sndPoisonMoan, sndBirdyLay, sndWhistle, sndBeeWater,
-            sndPiano0, sndPiano1, sndPiano2, sndPiano3, sndPiano4, sndPiano5, sndPiano6, sndPiano7, sndPiano8,
-            sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack,
-            sndComeonthen, sndParachute, sndBump, sndResurrector, sndPlane, sndTardis, sndFrozenHogImpact, sndIceBeam, sndHogFreeze
+            sndPiano0, sndPiano1, sndPiano2, sndPiano3, sndPiano4, sndPiano5, sndPiano6, sndPiano7,
+            sndPiano8, sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack,
+            sndComeonthen, sndParachute, sndBump, sndResurrector, sndPlane, sndTardis, sndFrozenHogImpact,
+            sndIceBeam, sndHogFreeze
             );
 
     // Available ammo types to be used by hedgehogs
@@ -153,7 +155,9 @@
             amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, // 35
             amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov, amBirdy, amPortalGun, // 42
             amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer, // 48
-            amResurrector, amDrillStrike, amSnowball, amTardis, {amStructure,} amLandGun, amIceGun, amKnife); // 54
+            amResurrector, amDrillStrike, amSnowball, amTardis, {amStructure,} amLandGun, amIceGun,
+            amKnife // 54
+            );
 
     // Different kind of crates that e.g. hedgehogs can pick up
     TCrateType = (HealthCrate, AmmoCrate, UtilityCrate);
@@ -168,11 +172,12 @@
             siMaxTeamKills, siMaxTurnSkips, siCustomAchievement, siGraphTitle,
             siPointType);
 
-    // Various "emote" animations a hedgehog can do
+    // Various 'emote' animations a hedgehog can do
     TWave = (waveRollup, waveSad, waveWave, waveHurrah, waveLemonade, waveShrug, waveJuggle);
 
     TRenderMode = (rmDefault, rmLeftEye, rmRightEye);
-    TStereoMode = (smNone, smRedCyan, smCyanRed, smRedBlue, smBlueRed, smRedGreen, smGreenRed, smHorizontal, smVertical);
+    TStereoMode = (smNone, smRedCyan, smCyanRed, smRedBlue, smBlueRed, smRedGreen, smGreenRed,
+                   smHorizontal, smVertical);
 
     THHFont = record
             Handle: PTTF_Font;
@@ -185,8 +190,8 @@
     TAmmo = record
             Propz: LongWord;
             Count: LongWord;
-(* Using for place hedgehogs mode, but for any other situation where the initial count would be needed I guess.
-For example, say, a mode where the weaponset is reset each turn, or on sudden death *)
+// Using for place hedgehogs mode, but for any other situation where the initial count would be needed I guess.
+// For example, say, a mode where the weaponset is reset each turn, or on sudden death
             NumPerTurn: LongWord;
             Timer: LongWord;
             Pos: LongWord;
@@ -225,10 +230,10 @@
     PClan     = ^TClan;
 
     TGearStepProcedure = procedure (Gear: PGear);
-// So, you're here looking for variables you can (ab)use to store some gear state?
+// So, you are here looking for variables you can (ab)use to store some gear state?
 // Not all members of this structure are created equal. Comments below are my take on what can be used for what in the gear structure.
     TGear = record
-// Don't ever override these.
+// Do *not* ever override these.
             NextGear, PrevGear: PGear;  // Linked list
             Z: Longword;                // Z index. For rendering. Sets order in list
             Active: Boolean;            // Is gear Active (running step code)
@@ -258,10 +263,10 @@
             Density   : hwFloat; // Density is kind of a mix of size and density. Impacts distance thrown, wind.
             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
             nImpactSounds: Word; // count of ImpactSounds.
-// Don't use these if you want to take damage normally, otherwise health/damage are commonly used for other purposes
+// Do not use these if you want to take damage normally, otherwise health/damage are commonly used for other purposes
             Invulnerable: Boolean;
             Health, Damage, Karma: LongInt;
-// DirAngle is a "real" - if you don't need it for rotation of sprite in uGearsRender, you can use it for any visual-only value
+// DirAngle is a 'real' - if you do not need it for rotation of sprite in uGearsRender, you can use it for any visual-only value
             DirAngle: real;
 // These are frequently overridden to serve some other purpose
             Pos: Longword;           // Commonly overridden.  Example use is posCase values in uConsts.
@@ -270,8 +275,8 @@
             Tag: LongInt;            // Quite generic. Variety of uses.
             FlightTime: Longword;    // Initially added for batting of hogs to determine homerun. Used for some firing delays
             MsgParam: LongWord;      // Initially stored a set of messages. So usually gm values like Message. Frequently overriden
-// These are not used generically, but should probably be used for purpose intended. Definitely shouldn't override pointer type
-            Tex: PTexture;          // A texture created by the gear. Shouldn't use for anything but textures
+// These are not used generically, but should probably be used for purpose intended. Definitely should not override pointer type
+            Tex: PTexture;          // A texture created by the gear. Should not use for anything but textures
             LinkedGear: PGear;      // Used to track a related gear. Portal pairs for example.
             Hedgehog: PHedgehog;    // set to CurrentHedgehog on gear creation
             SoundChannel: LongInt;  // Used to track a sound the gear started
@@ -405,12 +410,12 @@
     TClan = record
             Color: Longword;
             Teams: array[0..Pred(cMaxTeams)] of PTeam;
-        TeamsNumber: LongInt;{xymeng, org:LongWord}
+            TeamsNumber: LongInt;{xymeng, org:LongWord}
             TagTeamIndex: Longword;
             CurrTeam: LongWord;
             ClanHealth: LongInt;
             ClanIndex: LongInt;
-        TurnNumber: LongInt;{xymeng, org:LongWord}
+            TurnNumber: LongInt;{xymeng, org:LongWord}
             Flawless: boolean;
             end;
 
@@ -474,12 +479,12 @@
 
     POnScreenWidget = ^TOnScreenWidget;
     TOnScreenWidget = record
-        show          : boolean;                      // if false widget will not be drawn
-        sprite        : TSprite;                    // a convenience type
-        frame         : TSDL_Rect;                   // graphical coordinates
-        active        : TSDL_Rect;                  // active touch region
-        fadeAnimStart : Longword;            // time the fade started, 0 means don't fade
-        moveAnim      : TWidgetMovement;          // the animation associated to the widget
+        show          : boolean;             // if false widget will not be drawn
+        sprite        : TSprite;             // a convenience type
+        frame         : TSDL_Rect;           // graphical coordinates
+        active        : TSDL_Rect;           // active touch region
+        fadeAnimStart : Longword;            // time the fade started, 0 means do not fade
+        moveAnim      : TWidgetMovement;     // the animation associated to the widget
         end;
 
 {$IFDEF SDL13}