Set default water colours in greyscale mode in case the theme does not define them, decrement piano weapon on use
authornemo
Sun, 06 Nov 2011 13:53:25 -0500
changeset 6305 5f7480c2a08d
parent 6304 3036c242b19d
child 6306 553680d78546
Set default water colours in greyscale mode in case the theme does not define them, decrement piano weapon on use
hedgewars/GSHandlers.inc
hedgewars/uLandObjects.pas
hedgewars/uTextures.pas
--- a/hedgewars/GSHandlers.inc	Sun Nov 06 13:17:42 2011 -0500
+++ b/hedgewars/GSHandlers.inc	Sun Nov 06 13:53:25 2011 -0500
@@ -4423,15 +4423,15 @@
         end;
 
     if (*((Gear^.Pos = 3) and ((GameFlags and gfSolidLand) <> 0)) or*) (Gear^.Pos = 5) then
-        // bounce up to 10 times (3 times on gameflagged solid land) before dropping past landscape
-    begin
+        begin
         Gear^.dY := Gear^.dY + cGravity * 2;
         Gear^.Y := Gear^.Y + Gear^.dY;
         CheckGearDrowning(Gear);
         if (Gear^.State and gstDrowning) <> 0 then
-        begin
+            begin
+            OnUsedAmmo(CurrentHedgehog^);
             if CurrentHedgehog^.Gear <> nil then
-            begin
+                begin
                 // Drown the hedgehog.  Could also just delete it, but hey, this gets a caption
                 CurrentHedgehog^.Gear^.Active := true;
                 CurrentHedgehog^.Gear^.X := Gear^.X;
@@ -4439,19 +4439,20 @@
                 CurrentHedgehog^.Unplaced := false;
                 if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
                 TurnTimeLeft:= 0
+                end;
+            ResumeMusic
             end;
-            ResumeMusic
+        exit
         end;
-        exit
-    end;
 
     odY:= Gear^.dY;
     doStepFallingGear(Gear);
 
     if (Gear^.State and gstDrowning) <> 0 then
-    begin
+        begin
+        OnUsedAmmo(CurrentHedgehog^);
         if CurrentHedgehog^.Gear <> nil then
-        begin
+            begin
             // Drown the hedgehog.  Could also just delete it, but hey, this gets a caption
             CurrentHedgehog^.Gear^.Active := true;
             CurrentHedgehog^.Gear^.X := Gear^.X;
@@ -4459,20 +4460,20 @@
             CurrentHedgehog^.Unplaced := false;
             if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
             TurnTimeLeft:= 0
-        end;
+            end;
         ResumeMusic
-    end
+        end
     else if (Gear^.State and gstCollision) <> 0 then
         begin
-            r0 := GetRandom(21);
-            r1 := GetRandom(21);
-            doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, Gear^.Hedgehog, 0);
-            doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, Gear^.Hedgehog, 0);
-            doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, Gear^.Hedgehog, EXPLAutoSound);
-            for r0:= 0 to 4 do
-                AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
-            Gear^.dY := odY * -1 + cGravity * 2;
-            Gear^.Pos := Gear^.Pos + 1;
+        r0 := GetRandom(21);
+        r1 := GetRandom(21);
+        doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, Gear^.Hedgehog, 0);
+        doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, Gear^.Hedgehog, 0);
+        doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, Gear^.Hedgehog, EXPLAutoSound);
+        for r0:= 0 to 4 do
+            AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
+        Gear^.dY := odY * -1 + cGravity * 2;
+        Gear^.Pos := Gear^.Pos + 1;
         end
     else
         Gear^.dY := Gear^.dY + cGravity * 2;
--- a/hedgewars/uLandObjects.pas	Sun Nov 06 13:17:42 2011 -0500
+++ b/hedgewars/uLandObjects.pas	Sun Nov 06 13:53:25 2011 -0500
@@ -392,6 +392,26 @@
 begin
 
 AddProgress;
+// Set default water greyscale values
+if cGrayScale then
+    begin
+    for i:= 0 to 3 do
+        begin
+        t:= round(SDWaterColorArray[i].r * RGB_LUMINANCE_RED + SDWaterColorArray[i].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[i].b * RGB_LUMINANCE_BLUE);
+        if t > 255 then t:= 255;
+        SDWaterColorArray[i].r:= t;
+        SDWaterColorArray[i].g:= t;
+        SDWaterColorArray[i].b:= t
+        end;
+    for i:= 0 to 1 do
+        begin
+        t:= round(WaterColorArray[i].r * RGB_LUMINANCE_RED + WaterColorArray[i].g * RGB_LUMINANCE_GREEN + WaterColorArray[i].b * RGB_LUMINANCE_BLUE);
+        if t > 255 then t:= 255;
+        WaterColorArray[i].r:= t;
+        WaterColorArray[i].g:= t;
+        WaterColorArray[i].b:= t
+        end
+    end;
 
 s:= UserPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
 if not FileExists(s) then s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
--- a/hedgewars/uTextures.pas	Sun Nov 06 13:17:42 2011 -0500
+++ b/hedgewars/uTextures.pas	Sun Nov 06 13:53:25 2011 -0500
@@ -100,8 +100,7 @@
 end;
 
 procedure Surface2GrayScale(surf: PSDL_Surface);
-var tw, th, x, y: Longword;
-    tmpp: pointer;
+var tw, x, y: Longword;
     fromP4: PLongWordArray;
 begin
 fromP4:= Surf^.pixels;