Merge pull request #7 from LocutusOfBorg/fix-FPIC
authorVittorio Giovara <vittorio.giovara@gmail.com>
Fri, 03 Jan 2014 07:09:28 -0800
changeset 9923 5071f5682733
parent 9920 ad926d410003 (diff)
parent 9921 7227cc2acba1 (current diff)
child 9925 113e61a8cadc
child 9927 22bb4dfbfea8
Merge pull request #7 from LocutusOfBorg/fix-FPIC Fixed fPIC link failure with arm and sparc architectures, fixing issue #757
--- a/hedgewars/uGearsHedgehog.pas	Fri Jan 03 13:07:19 2014 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Fri Jan 03 07:09:28 2014 -0800
@@ -1029,7 +1029,7 @@
     begin
     Gear^.State:= Gear^.State and (not gstWinner);
     Gear^.State:= Gear^.State and (not gstMoving);
-    while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) and (Gear <> nil) do
+    while (not CheckGearDrowning(Gear)) and (Gear <> nil) and (TestCollisionYWithGear(Gear,1) = 0) do
         Gear^.Y:= Gear^.Y + _1;
 
     // could become nil in CheckGearDrowning if ai's hog fails to respawn in ai survival
@@ -1061,7 +1061,6 @@
         Gear^.State:= Gear^.State and not gstCollision 
         end;
 
-    CheckGearDrowning(Gear);
     // could become nil if ai's hog fails to respawn in ai survival
     if Gear = nil then exit;
     // hide target cursor if current hog is drowning
@@ -1340,6 +1339,8 @@
 procedure doStepHedgehog(Gear: PGear);
 var tX: hwFloat;
 begin
+CheckGearDrowning(Gear);
+if Gear = nil then exit;
 tX:= Gear^.X;
 if WorldWrap(Gear) then
     begin
--- a/hedgewars/uScript.pas	Fri Jan 03 13:07:19 2014 +0100
+++ b/hedgewars/uScript.pas	Fri Jan 03 07:09:28 2014 -0800
@@ -1163,13 +1163,15 @@
             begin
             gear^.Health:= lua_tointeger(L, 2);
 
-        if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
-            begin
-            RenderHealth(gear^.Hedgehog^);
-            RecountTeamHealth(gear^.Hedgehog^.Team)
-            end;
-
-            SetAllToActive;
+            if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
+                begin
+                RenderHealth(gear^.Hedgehog^);
+                RecountTeamHealth(gear^.Hedgehog^.Team)
+                end;
+            // Why did this do a "setalltoactive" ?
+            //SetAllToActive;  
+            Gear^.Active:= true;
+            AllInactive:= false
             end
         end;
     lc_sethealth:= 0
@@ -1919,6 +1921,30 @@
     lc_setgravity:= 0
 end;
 
+function lc_setwaterline(L : Plua_State) : LongInt; Cdecl;
+var iterator: PGear;
+begin
+    if lua_gettop(L) <> 1 then
+         LuaParameterCountError('SetWaterLine', 'waterline', lua_gettop(L))
+    else
+        begin
+        cWaterLine:= lua_tointeger(L,1);
+        AllInactive:= false;
+        iterator:= GearsList;
+        while iterator <> nil do
+            begin
+            if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then
+                begin
+                iterator^.Active:= true;
+                if iterator^.dY.QWordValue = 0 then iterator^.dY.isNegative:= false;
+                iterator^.State:= iterator^.State or gstMoving;
+                DeleteCI(iterator)
+                end;
+            iterator:= iterator^.NextGear
+            end
+        end;
+    lc_setwaterline:= 0
+end;
 
 function lc_setaihintsongear(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
@@ -2599,6 +2625,7 @@
 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle);
 lua_register(luaState, _P'GetGravity', @lc_getgravity);
 lua_register(luaState, _P'SetGravity', @lc_setgravity);
+lua_register(luaState, _P'SetWaterLine', @lc_setwaterline);
 
 lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear);
 lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload);