Skip rerendering the caption if the text is unchanged. Scripts make heavy use of caption, often onGameTick 0.9.17
authornemo
Mon, 14 Nov 2011 13:13:38 -0500
branch0.9.17
changeset 6371 c6f73d8e87e2
parent 6370 fb9aeddcb046
child 6372 b392132a588c
Skip rerendering the caption if the text is unchanged. Scripts make heavy use of caption, often onGameTick
hedgewars/uCaptions.pas
--- a/hedgewars/uCaptions.pas	Mon Nov 14 13:28:16 2011 +0400
+++ b/hedgewars/uCaptions.pas	Mon Nov 14 13:13:38 2011 -0500
@@ -35,17 +35,24 @@
 type TCaptionStr = record
                    Tex: PTexture;
                    EndTime: LongWord;
+                   Text: shortstring;
                    end;
 var
     Captions: array[TCapGroup] of TCaptionStr;
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 begin
-    if Captions[Group].Tex <> nil then
+    if (Captions[Group].Tex <> nil) and (Captions[Group].Text <> s) then
+        begin
         FreeTexture(Captions[Group].Tex);
-    Captions[Group].Tex:= nil;
-
-    Captions[Group].Tex:= RenderStringTex(s, Color, fntBig);
+        Captions[Group].Tex:= nil
+        end;
+    
+    if Captions[Group].Text <> s then
+        begin
+        Captions[Group].Text:= s;
+        Captions[Group].Tex:= RenderStringTex(s, Color, fntBig)
+        end;
 
     case Group of
         capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200