simplify some code
authorsheepluva
Sat, 05 Jul 2014 18:51:45 +0200
changeset 10352 2af2309207b0
parent 10351 0eff41e9f63f
child 10353 25f325b48a6c
child 10354 56bd029245fc
simplify some code
hedgewars/uGearsHandlersMess.pas
hedgewars/uVisualGearsList.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jul 05 15:28:32 2014 +0400
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Jul 05 18:51:45 2014 +0200
@@ -673,11 +673,7 @@
     or (Gear^.Kind = gtBall) then
         CalcRotationDirAngle(Gear)
     else if (GameTicks and $1F) = 0 then
-        begin
-        if hwRound(Gear^.Y) > cWaterLine then
-             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble)
-        else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
-        end
+        AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -694,11 +690,7 @@
         exit
         end;
     if (GameTicks and $3F) = 0 then
-        begin
-        if hwRound(Gear^.Y) > cWaterLine then
-             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble)
-        else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
-        end
+        AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1001,12 +993,8 @@
         if (GameTicks and $F) = 0 then
             begin
             if (GameTicks and $30) = 0 then
-                begin
-                if nuw then
-                    AddVisualGear(gX, gY, vgtBubble)
-                else
-                    AddVisualGear(gX, gY, vgtBeeTrace);
-                end;
+                AddVisualGear(gX, gY, vgtBeeTrace);
+
             Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX));
             Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY));
             // make sure new speed isn't higher than original one (which we stored in Friction variable)
@@ -2765,11 +2753,7 @@
         end;
 
     if (GameTicks and $3F) = 0 then
-        begin
-        if hwRound(Gear^.Y) > cWaterLine then
-             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble)
-        else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
-        end
+        AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -3270,11 +3254,7 @@
     doStepFallingGear(Gear);
 
     if (GameTicks and $3F) = 0 then
-        begin
-        if hwRound(Gear^.Y) > cWaterLine then
-             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble)
-        else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
-        end;
+        AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
 
     if ((Gear^.State and gstCollision) <> 0) then
         begin
--- a/hedgewars/uVisualGearsList.pas	Sat Jul 05 15:28:32 2014 +0400
+++ b/hedgewars/uVisualGearsList.pas	Sat Jul 05 18:51:45 2014 +0200
@@ -40,6 +40,10 @@
 
 function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline;
 begin
+    // adjust some visual gear types if underwater
+    if (Y > cWaterLine) and ((Kind = vgtBeeTrace) or (Kind = vgtSmokeTrace) or (Kind = vgtEvilTrace)) then
+        Kind:= vgtBubble;
+
     AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false, -1);
 end;