Small patch to make Civ3 a bit happier

Lionel Ulmer lionel.ulmer at
Tue Jul 23 14:53:50 CDT 2002

Hi all,

Civ3 seems to have a bug in one of his code path (in the sense that if a
function fails, it goes in a function that triggers a division by zero). The
offending function is 'CreateScalableFontResourceA'. Thanks to Ove and David
for pointing to me this fact (that I would have spend ages finding on my own
:-) ).

One easy way to fix it would be to always return TRUE here and that would
fix Civ3. But a nicer way (and also correct way) to have the same effect is
to take into account the fact that if you ever played it under Windows, the
'.fot' file (that should be created by 'CreateScalableFontResourceA') is
still present. And that should make the function fail.

And for people not having played it with Windows, they can always do a
'touch LSANS.fot' in the Civ3 directory to make it run :-)

Now, the very best way would be to know the .FOT file format and to create
one when this function is called (and also enable .FOT font loading later
on). But I will let this as an exercise for motivated font / ressource gurus

  Properly check that the font ressource is not already there.


		 Lionel Ulmer -
-------------- next part --------------
Index: objects/font.c
RCS file: /home/wine/wine/objects/font.c,v
retrieving revision 1.76
diff -u -r1.76 font.c
--- objects/font.c	22 Jun 2002 01:19:29 -0000	1.76
+++ objects/font.c	23 Jul 2002 19:53:38 -0000
@@ -1964,6 +1964,8 @@
                                              LPCSTR lpszFontFile,
                                              LPCSTR lpszCurrentPath )
+    HANDLE f;
     /* fHidden=1 - only visible for the calling app, read-only, not
      * enumbered with EnumFonts/EnumFontFamilies
      * lpszCurrentPath can be NULL
@@ -1971,6 +1973,13 @@
     FIXME("(%ld,%s,%s,%s): stub\n",
           fHidden, debugstr_a(lpszResourceFile), debugstr_a(lpszFontFile),
           debugstr_a(lpszCurrentPath) );
+    /* If the output file already exists, return the ERROR_FILE_EXISTS error as specified in MSDN */
+    if ((f = CreateFileA(lpszResourceFile, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) {
+        CloseHandle(f);
+        SetLastError(ERROR_FILE_EXISTS);
+        return FALSE;
+    }
     return FALSE; /* create failed */

More information about the wine-patches mailing list