Fix speech bubble briefly rendering at (0,0) after spawning
authorWuzzy <Wuzzy2@mail.ru>
Sat, 17 Mar 2018 04:37:13 +0100
changeset 13240 9f5023a5f9e1
parent 13239 6fa6626eb273
child 13241 ef1393c6bd12
Fix speech bubble briefly rendering at (0,0) after spawning
hedgewars/uVisualGears.pas
hedgewars/uVisualGearsHandlers.pas
--- a/hedgewars/uVisualGears.pas	Sat Mar 17 04:12:10 2018 +0100
+++ b/hedgewars/uVisualGears.pas	Sat Mar 17 04:37:13 2018 +0100
@@ -264,16 +264,16 @@
                         else
                             DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
                         end;*)
-               vgtSpeechBubble: begin
-                                if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
-                                    begin
-                                    tinted:= true;
-                                    Tint($FF, $FF, $FF,  $66);
-                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
-                                    end
-                                else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and ((Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Team = CurrentTeam))) or (Gear^.State = 2)) then
-                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
-                                end;
+               vgtSpeechBubble: if (Gear^.Angle <> 0) then
+                                // ^ Before this gear renders, Angle must be set to mark it ready (e.g. coordinates properly initialized)
+                                    if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
+                                        begin
+                                        tinted:= true;
+                                        Tint($FF, $FF, $FF,  $66);
+                                        DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
+                                        end
+                                    else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and ((Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Team = CurrentTeam))) or (Gear^.State = 2)) then
+                                        DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
                vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
                vgtHealthTag: if Gear^.Tex <> nil then
                                begin
--- a/hedgewars/uVisualGearsHandlers.pas	Sat Mar 17 04:12:10 2018 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Sat Mar 17 04:37:13 2018 +0100
@@ -640,12 +640,14 @@
         begin
         Gear^.X:= hwFloat2Float(realgear^.X) + (Gear^.Tex^.w div 2  - Gear^.Tag);
         Gear^.Y:= hwFloat2Float(realgear^.Y) - (realgear^.Radius + Gear^.Tex^.h);
+        Gear^.Angle:= 1; // Mark speech bubble as ready for rendering
         end
     end
 else if Gear^.Hedgehog^.Gear <> nil then
     begin
     Gear^.X:= hwFloat2Float(Gear^.Hedgehog^.Gear^.X) + (Gear^.Tex^.w div 2  - Gear^.Tag);
     Gear^.Y:= hwFloat2Float(Gear^.Hedgehog^.Gear^.Y) - (cHHRadius + Gear^.Tex^.h);
+    Gear^.Angle:= 1; // Mark speech bubble as ready for rendering
     end;
 
 if (Gear^.Timer = 0) or ((realgear = nil) and (Gear^.Frame <> 0))  then