pull bugfix into 0.9.14 avoid major performance hit when using flamethrower 0.9.14
authornemo
Fri, 12 Nov 2010 17:53:35 -0500
branch0.9.14
changeset 4251 4b7d3507d175
parent 4249 f6d0b8445cac
child 4253 160f987a5d9f
pull bugfix into 0.9.14 avoid major performance hit when using flamethrower
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Fri Nov 12 21:42:27 2010 +0300
+++ b/hedgewars/GSHandlers.inc	Fri Nov 12 17:53:35 2010 -0500
@@ -3049,17 +3049,19 @@
 
     // erases them all at once :-/
     if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
-    begin
+        begin
         Gear^.Timer := 0;
         Gear^.MsgParam := 0
-    end;
+        end;
 
     if Gear^.Health < 0 then Gear^.Health := 0;
-    if (GameTicks and $3F) = 0 then
+    i:= Gear^.Health div 20;
+    if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
         begin
+        Gear^.Damage:= i;
         //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate);
         if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
-        Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) +
+        Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) +
                      '%', cWhiteColor, fntSmall)
         end;
 
@@ -3986,7 +3988,7 @@
 var 
     HHGear: PGear;
     rx, ry, speed: hwFloat;
-    gX, gY: LongInt;
+    i, gX, gY: LongInt;
     Fire: PGear;
 begin
     AllInactive := false;
@@ -3996,25 +3998,25 @@
     gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle);
     
     if (GameTicks and $FF) = 0 then
-    begin
+        begin
         if (HHGear^.Message and gmRight) <> 0 then
-        begin
+            begin
             if HHGear^.dX.isNegative and (Gear^.Tag < 20) then inc(Gear^.Tag)
             else if Gear^.Tag > 5 then dec(Gear^.Tag);
-        end
+            end
         else if (HHGear^.Message and gmLeft) <> 0 then
-        begin
+            begin
             if HHGear^.dX.isNegative and (Gear^.Tag > 5) then dec(Gear^.Tag)
             else if Gear^.Tag < 20 then inc(Gear^.Tag);
-        end
-    end;
+            end
+        end;
     
     dec(Gear^.Timer);
     if Gear^.Timer = 0 then
-    begin
+        begin
         dec(Gear^.Health);
         if (Gear^.Health mod 10) = 0 then
-        begin
+            begin
             rx := rndSign(getRandom * _0_1);
             ry := rndSign(getRandom * _0_1);
             speed := _0_8 * (_10 / Gear^.Tag);
@@ -4028,21 +4030,26 @@
                 Fire := AddGear(gx, gy, gtFlame, 0,
                             SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
-        end;
+            end;
         Gear^.Timer:= Gear^.Tag
-    end;
+        end;
 
     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then
-    begin
+        begin
         DeleteGear(Gear);
         AfterAttack
-    end
+        end
     else
-    begin
-        if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
-        Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 5)) +
-                     '%', cWhiteColor, fntSmall) 
-    end
+        begin
+        i:= Gear^.Health div 5;
+        if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
+            begin
+            Gear^.Damage:= i;
+            if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
+            Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) +
+                         '%', cWhiteColor, fntSmall)
+            end
+        end
 end;
 
 procedure doStepFlamethrower(Gear: PGear);
--- a/hedgewars/uGears.pas	Fri Nov 12 21:42:27 2010 +0300
+++ b/hedgewars/uGears.pas	Fri Nov 12 17:53:35 2010 -0500
@@ -494,6 +494,7 @@
                 end;
      gtJetpack: begin
                 gear^.Health:= 2000;
+                gear^.Damage:= 100
                 end;
      gtMolotov: begin
                 gear^.Radius:= 6;
@@ -531,6 +532,7 @@
                 gear^.Tag:= 10;
                 gear^.Timer:= 10;
                 gear^.Health:= 500;
+                gear^.Damage:= 100;
                 end;
  gtPoisonCloud: begin
                 gear^.Timer:= 5000;