Fix engine crash when using alt damage option
authorunc0rr
Mon, 19 Jan 2009 19:04:16 +0000
changeset 1729 a9f2d8564128
parent 1727 bddbb2400c30
child 1733 419e9dfce35d
Fix engine crash when using alt damage option
hedgewars/uVisualGears.pas
--- a/hedgewars/uVisualGears.pas	Mon Jan 19 18:50:23 2009 +0000
+++ b/hedgewars/uVisualGears.pas	Mon Jan 19 19:04:16 2009 +0000
@@ -56,13 +56,18 @@
 
 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
 var s: shortstring;
+	Gear: PVisualGear;
 begin
 if cAltDamage then
-	with AddVisualGear(X, Y, vgtSmallDamageTag)^ do
-		begin
-		str(Damage, s);
-		Tex:= RenderStringTex(s, Color, fntSmall);
-		end;
+	begin
+	Gear:= AddVisualGear(X, Y, vgtSmallDamageTag);
+	if Gear <> nil then
+		with Gear^ do
+			begin
+			str(Damage, s);
+			Tex:= RenderStringTex(s, Color, fntSmall);
+			end
+	end
 end;