Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
authorunc0rr
Fri, 27 Oct 2006 14:30:36 +0000
changeset 206 32fa6282efe2
parent 205 8d9aff55e6ab
child 207 287077789132
Add workaround over freepascal bug (http://www.freepascal.org/mantis/view.php?id=7613)
hedgewars/SDLh.pas
hedgewars/uStore.pas
--- a/hedgewars/SDLh.pas	Thu Oct 26 16:08:29 2006 +0000
+++ b/hedgewars/SDLh.pas	Fri Oct 27 14:30:36 2006 +0000
@@ -107,10 +107,15 @@
 
      PSDL_Color = ^TSDL_Color;
      TSDL_Color = record
-                  r: Byte;
-                  g: Byte;
-                  b: Byte;
-                  unused: Byte;
+                  case byte of
+                       0: (r: Byte;
+                           g: Byte;
+                           b: Byte;
+                           unused: Byte;
+                          );
+(* workaround over freepascal bug.
+   See http://www.freepascal.org/mantis/view.php?id=7613 for details *)
+                       1: (value: Longword);
                   end;
 
      PSDL_RWops = ^TSDL_RWops;
@@ -239,8 +244,11 @@
 
 
 function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: integer): integer; cdecl; external SDL_TTFLibName;
-function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
-function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
+(* TSDL_Color -> Longword conversion is workaround over freepascal bug.
+   See http://www.freepascal.org/mantis/view.php?id=7613 for details *)
+function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName;
+function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName;
+
 function TTF_OpenFont(const filename: PChar; size: integer): PTTF_Font; cdecl; external SDL_TTFLibName;
 procedure TTF_SetFontStyle(font: PTTF_Font; style: integer); cdecl; external SDL_TTFLibName;
 
--- a/hedgewars/uStore.pas	Thu Oct 26 16:08:29 2006 +0000
+++ b/hedgewars/uStore.pas	Fri Oct 27 14:30:36 2006 +0000
@@ -108,7 +108,7 @@
 clr.r:= Color shr 16;
 clr.g:= (Color shr 8) and $FF;
 clr.b:= Color and $FF;
-tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
+tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr.value);
 Result.x:= X + FontBorder + 2;
 Result.y:= Y + FontBorder;
 SDLTry(tmpsurf <> nil, true);
@@ -375,7 +375,7 @@
 clr.r:= $FF;
 clr.g:= $FF;
 clr.b:= $FF;
-tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
+tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr.value);
 SDLTry(tmpsurf <> nil, true);
 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
 SDL_FreeSurface(tmpsurf)