# HG changeset patch # User alfadur # Date 1557918735 -10800 # Node ID 088c1d3196128cfb4e8510223a813add5473ed12 # Parent f59b7f5cf6e88c922f19188656b34289e8df3faa if at all possible, don't regenerate arbitrary number of health textures each tick diff -r f59b7f5cf6e8 -r 088c1d319612 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Wed May 15 09:08:39 2019 +0200 +++ b/hedgewars/uGearsHandlersMess.pas Wed May 15 14:12:15 2019 +0300 @@ -2394,13 +2394,19 @@ AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke) else AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); - // health texture - FreeAndNilTexture(Gear^.Tex); - Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff808080, fnt16); + dec(Gear^.Health, Gear^.Damage); Gear^.Damage := 0; if Gear^.Health <= 0 then - doStepCase(Gear); + doStepCase(Gear) + else + // health texture (FlightTime = health when the last texture was generated) + if Gear^.Health <> Gear^.FlightTime then + begin + Gear^.FlightTime:= Gear^.Health; + FreeAndNilTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff808080, fnt16); + end; end; procedure doStepCase(Gear: PGear); @@ -2469,18 +2475,22 @@ AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke) else AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); + dec(Gear^.Health, Gear^.Damage); Gear^.Damage := 0; - // health texture - FreeAndNilTexture(Gear^.Tex); - Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff808080, fnt16); + // health texture (FlightTime = health when the last texture was generated) + if Gear^.Health <> Gear^.FlightTime then + begin + Gear^.FlightTime:= Gear^.Health; + FreeAndNilTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff808080, fnt16); + end; end else begin // health texture for health crate - if (k = gtCase) and ((Gear^.Pos and $02) <> 0) then - begin - FreeAndNilTexture(Gear^.Tex); + if (k = gtCase) and ((Gear^.Pos and posCaseHealth) <> 0) then + begin if ((Gear^.State and gstFrozen) = 0) then begin // Karma=2: Always hide health @@ -2496,9 +2506,23 @@ else i:= 1; if i = 1 then - Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff80ff80, fnt16) + begin + if Gear^.Health <> Gear^.FlightTime then + begin + Gear^.FlightTime:= Gear^.Health; + FreeAndNilTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(ansistring(inttostr(Gear^.Health)), $ff80ff80, fnt16) + end + end else - Gear^.Tex := RenderStringTex(trmsg[sidUnknownGearValue], $ff80ff80, fnt16) + begin + if Gear^.FlightTime <> $ffffffff then + begin + Gear^.FlightTime:= $ffffffff; + FreeAndNilTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(trmsg[sidUnknownGearValue], $ff80ff80, fnt16) + end + end end; end; if Gear^.Timer = 500 then diff -r f59b7f5cf6e8 -r 088c1d319612 hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Wed May 15 09:08:39 2019 +0200 +++ b/hedgewars/uGearsRender.pas Wed May 15 14:12:15 2019 +0300 @@ -1656,7 +1656,7 @@ begin if isShowGearInfo and (Gear^.RenderHealth) and (Gear^.Tex <> nil) then begin - if (Gear^.Kind = gtCase) and ((Gear^.Pos and $02) <> 0) then + if (Gear^.Kind = gtCase) and ((Gear^.Pos and posCaseHealth) <> 0) then DrawTextureCentered(x, y - 38, Gear^.Tex); if (Gear^.Kind = gtExplosives) then DrawTextureCentered(x, y - 38, Gear^.Tex);