Refactor IsTooDarkToRead to fix pas2c crash
authorWuzzy <Wuzzy2@mail.ru>
Tue, 02 Apr 2019 22:40:46 +0200
changeset 14766 7cc768094d66
parent 14765 f5dadf2b7d03
child 14767 a8a328ac3cac
Refactor IsTooDarkToRead to fix pas2c crash
hedgewars/uRenderUtils.pas
--- a/hedgewars/uRenderUtils.pas	Tue Apr 02 18:59:38 2019 +0200
+++ b/hedgewars/uRenderUtils.pas	Tue Apr 02 22:40:46 2019 +0200
@@ -78,18 +78,13 @@
     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
 end;*)
 
-function IsTooDarkToRead(TextColor: LongWord): boolean;
+function IsTooDarkToRead(TextColor: LongWord): boolean; inline;
 var clr: TSDL_Color;
 begin
     clr.r:= (TextColor shr 16) and $FF;
     clr.g:= (TextColor shr 8) and $FF;
     clr.b:= TextColor and $FF;
-    IsTooDarkToRead:= ((clr.r >= cInvertTextColorAt) or (clr.g >= cInvertTextColorAt) or (clr.b >= cInvertTextColorAt));
-end;
-
-function IsTooDarkToRead(TextColor: TSDL_COLOR): boolean;
-begin
-    IsTooDarkToRead:= (not ((TextColor.r >= cInvertTextColorAt) or (TextColor.g >= cInvertTextColorAt) or (TextColor.b >= cInvertTextColorAt)));
+    IsTooDarkToRead:= not ((clr.r >= cInvertTextColorAt) or (clr.g >= cInvertTextColorAt) or (clr.b >= cInvertTextColorAt));
 end;
 
 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect;
@@ -111,7 +106,7 @@
     clr.r:= (Color shr 16) and $FF;
     clr.g:= (Color shr 8) and $FF;
     clr.b:= Color and $FF;
-    if (not IsTooDarkToRead(clr)) then
+    if (not IsTooDarkToRead(Color)) then
         DrawRoundRect(@finalRect, cWhiteColor, cNearBlackColor, Surface, true)
     else
         DrawRoundRect(@finalRect, cNearBlackColor, cWhiteColor, Surface, true);