Fix crash when spawning vgtSmallDamageTag in Lua
authorWuzzy <Wuzzy2@mail.ru>
Sun, 13 Dec 2020 21:16:25 +0100
changeset 15772 95db10dcad71
parent 15771 aa4a4e222308
child 15773 da1bb21e6fbf
Fix crash when spawning vgtSmallDamageTag in Lua
ChangeLog.txt
hedgewars/uVisualGears.pas
hedgewars/uVisualGearsHandlers.pas
--- a/ChangeLog.txt	Mon Dec 07 16:59:44 2020 +0100
+++ b/ChangeLog.txt	Sun Dec 13 21:16:25 2020 +0100
@@ -54,6 +54,7 @@
 
 Lua:
  + Add RopeKnocking library
+ * Fix crash when spawning a vgtSmallDamageTag
 
 ====================== 1.0.0 =======================
 Highlights:
--- a/hedgewars/uVisualGears.pas	Mon Dec 07 16:59:44 2020 +0100
+++ b/hedgewars/uVisualGears.pas	Sun Dec 13 21:16:25 2020 +0100
@@ -265,7 +265,8 @@
                                         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);
+               vgtSmallDamageTag: if Gear^.Tex <> nil then
+                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
                vgtHealthTag: if Gear^.Tex <> nil then
                                begin
                                if Gear^.Frame = 0 then
--- a/hedgewars/uVisualGearsHandlers.pas	Mon Dec 07 16:59:44 2020 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Sun Dec 13 21:16:25 2020 +0100
@@ -403,8 +403,14 @@
 end;
 
 procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
+var s: shortstring;
 begin
 Gear^.Y:= Gear^.Y - 0.02 * Steps;
+if Gear^.Tex = nil then
+    begin
+    s:= IntToStr(Gear^.State);
+    Gear^.Tex:= RenderStringTex(ansistring(s), cWhiteColor, fntSmall);
+    end;
 
 if Gear^.FrameTicks <= Steps then
     DeleteVisualGear(Gear)