[HomeworldSDL] revision 289

HomeworldSDL subversion at homeworldsdl.org
Mon Nov 20 12:24:45 GMT 2006


----------------------------------------------------------------------
r289 | aunxx | 2006-11-20 12:24:44 +0000 (Mon, 20 Nov 2006)

Complete update to gcc v4 compatibilty by removing the reference to
writable-strings.
Modification to Tutor.c which is the only code requiring this option.

Update to INSTALL to reflect changes.


----------------------------------------------------------------------

Modified: homeworld/trunk/Linux/INSTALL
===================================================================
--- homeworld/trunk/Linux/INSTALL	2006-11-20 00:37:57 UTC (rev 288)
+++ homeworld/trunk/Linux/INSTALL	2006-11-20 12:24:44 UTC (rev 289)
@@ -38,10 +38,8 @@
 
 GCC 3.x versions prior to 3.3 have problems compiling various sections of the Homeworld code and will crash upon the attempt.  GCC 2.95.x does not provide support for SSE/SSE2 instructions and will not work. 
  
- GCC 4 will not work either, as several sections of the source code rely on obsolete programming practices no longer permitted by GCC 4 and later... most notably the mission source files use the "-fwritable-strings" option which GCC 4 no longer allows. You'll have to run GCC as GCC 3.3 or 3.4.
+GCC 4.x is now working after resolving cast and compile issues, and removing the requirement to use -fwritable strings.
 
- GCC 4 is now working but a change needs to be made to ../src/Generated/Makefile.am before configure or src/Generated/Makefile after configure to allow the compile to work. The change is to remove writable-strings as a compile option for the Missions. This has been tested but I am unable to find a justification for the writable-strings. If it breaks things I'll look at fixing specific parts.
-
 There is a strong sentiment among many people to rewrite the codebase to modern standards, and even talk of aiming for a 64-bit branch as well, but it will take time. 
  
  -Compiling the source code-

Modified: homeworld/trunk/src/Game/Tutor.c
===================================================================
--- homeworld/trunk/src/Game/Tutor.c	2006-11-20 00:37:57 UTC (rev 288)
+++ homeworld/trunk/src/Game/Tutor.c	2006-11-20 12:24:44 UTC (rev 289)
@@ -58,7 +58,7 @@
 
 // Function declarations
 void utySinglePlayerGameStart(char *name, featom *atom);
-char *tutGetNextTextLine(char *pDest, char *pString, long Width);
+char *tutGetNextTextLine(char *pDest, char *pString, long Width, int pDestSize);
 udword tutProcessNextButton(struct tagRegion *reg, sdword ID, udword event, udword data);
 udword tutProcessBackButton(struct tagRegion *reg, sdword ID, udword event, udword data);
 udword uicButtonProcess(regionhandle region, sdword ID, udword event, udword data);
@@ -973,7 +973,7 @@
     currFont = fontMakeCurrent(tutTextFont);
 
     do {
-        pString = tutGetNextTextLine(Line, pString, tutTextSizeX);
+        pString = tutGetNextTextLine(Line, pString, tutTextSizeX, 256); // 256 defined above as size of Line
         Height += fontHeight(" ");
     } while(pString && pString[0]);
 
@@ -1041,7 +1041,7 @@
 
 // This function gets a line of text that is up to Width pixels wide, and returns a
 // pointer to the start of the next line.  Assumes the current font is set.
-char *tutGetNextTextLine(char *pDest, char *pString, long Width)
+char *tutGetNextTextLine(char *pDest, char *pString, long Width, int pDestSize)
 {
 long    WordLen, StringLen;
 char    *pstr;
@@ -1055,9 +1055,17 @@
     if(pString[0] == 0)
         return NULL;
 
+    if (strlen(pString) < pDestSize) {
+	memStrncpy(pDest, pString, strlen(pString) +1);
+    }
+    else {
+	memStrncpy(pDest, pString, pDestSize -1);
+	memStrncpy(pDest + pDestSize -1, '\0', 1);
+    }
+
     do {
         // Skip leading whitespace
-        pstr = &pString[StringLen];
+        pstr = &pDest[StringLen];
         while( *pstr && *pstr != '\n' && (*pstr == '-' || tutIsspace(*pstr)) )
         {
             WordLen++;
@@ -1074,7 +1082,7 @@
 
             temp = *pstr;
             *pstr = 0;
-            if(fontWidth(pString) > Width)
+            if(fontWidth(pDest) > Width)
                 Done = TRUE;
             else
             {
@@ -1092,8 +1100,8 @@
 
     if(StringLen)
     {
-        memStrncpy(pDest, pString, StringLen+1);
-        //pDest[StringLen] = 0;
+        // memStrncpy(pDest, pString, StringLen+1);
+        pDest[StringLen] = 0;
 
         while( pString[StringLen] && tutIsspace(pString[StringLen]) )
             StringLen++;
@@ -1443,7 +1451,7 @@
     pString = (char *)pAtom->pData;
 
     do {
-        pString = tutGetNextTextLine(Line, pString, Width);
+        pString = tutGetNextTextLine(Line, pString, Width, 256); //256 defined above as size of Line
         if(Line[0])
             fontPrintf(x, y, colRGB(255, 255, 128), "%s", Line);
         y += fontHeight(" ");

Modified: homeworld/trunk/src/Generated/Makefile.am
===================================================================
--- homeworld/trunk/src/Generated/Makefile.am	2006-11-20 00:37:57 UTC (rev 288)
+++ homeworld/trunk/src/Generated/Makefile.am	2006-11-20 12:24:44 UTC (rev 289)
@@ -3,10 +3,9 @@
 # We need to write to the strings defined in the mission code files (only
 # temporary writes, for things such as checking the pixel width of a section
 # of a string).
-AM_CFLAGS = -fwritable-strings
-# The enty above needs commenting out and the below line un-commenting 
-# to allow the GCC v4 build to work.
-# AM_CFLAGS = 
+# AM_CFLAGS = -fwritable-strings
+# The enty above is now obsolete.
+AM_CFLAGS = 
 
 noinst_LIBRARIES = libhw_Generated.a
 libhw_Generated_a_SOURCES = Mission01.c Mission01.func.c Mission01.h Mission02.c Mission02.func.c Mission02.h Mission03.c Mission03.func.c Mission03.h Mission04.c Mission04.func.c Mission04.h Mission05.c Mission05.func.c Mission05.h Mission06.c Mission06.func.c Mission06.h Mission07.c Mission07.func.c Mission07.h Mission08.c Mission08.func.c Mission08.h Mission09.c Mission09.func.c Mission09.h Mission10.c Mission10.func.c Mission10.h Mission11.c Mission11.func.c Mission11.h Mission12.c Mission12.func.c Mission12.h Mission13.c Mission13.func.c Mission13.h Mission14.c Mission14.func.c Mission14.h Mission15.c Mission15.func.c Mission15.h Mission16.c Mission16.func.c Mission16.h Tutorial1.c Tutorial1.func.c Tutorial1.h




More information about the Commits mailing list