fix speechbubbles assigning negative values to a Longword value, overflowing it
authorsheepluva
Sun, 08 Dec 2013 02:36:14 +0100 (2013-12-08)
changeset 9761 b497a6c679cb
parent 9760 395ca7fe6362
child 9762 938d1c08d0d1
fix speechbubbles assigning negative values to a Longword value, overflowing it
hedgewars/uVisualGearsHandlers.pas
--- a/hedgewars/uVisualGearsHandlers.pas	Fri Dec 06 23:53:35 2013 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Sun Dec 08 02:36:14 2013 +0100
@@ -614,10 +614,11 @@
 
 Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16);
 
+// FrameTicks cannot hold negative values
 case Gear^.FrameTicks of
-    1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28;
-    2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20;
-    3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10;
+    1: Gear^.FrameTicks:= max(0,SpritesData[sprSpeechTail].Width-28);
+    2: Gear^.FrameTicks:= max(0,SpritesData[sprThoughtTail].Width-20);
+    3: Gear^.FrameTicks:= max(0,SpritesData[sprShoutTail].Width-10);
     end;
 
 Gear^.doStep:= @doStepSpeechBubbleWork;