unsynced remote changes...
authorkoda
Fri, 03 Jan 2014 15:24:22 +0100
changeset 9920 ad926d410003
parent 9917 1ca194a8b509 (diff)
parent 9918 ca90e470333b (current diff)
child 9923 5071f5682733
unsynced remote changes...
--- a/hedgewars/uGearsHedgehog.pas	Fri Jan 03 05:58:18 2014 -0800
+++ b/hedgewars/uGearsHedgehog.pas	Fri Jan 03 15:24:22 2014 +0100
@@ -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 05:58:18 2014 -0800
+++ b/hedgewars/uScript.pas	Fri Jan 03 15:24:22 2014 +0100
@@ -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);