merge gtkgensurf from ZeroRadiant trunk
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Mon, 4 Jan 2010 10:38:49 +0000 (10:38 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Mon, 4 Jan 2010 10:38:49 +0000 (10:38 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@408 61c419a2-8eb2-4b30-bcec-8cead039b335

contrib/gtkgensurf/bitmap.cpp
contrib/gtkgensurf/dec.cpp
contrib/gtkgensurf/font.cpp
contrib/gtkgensurf/gendlgs.cpp
contrib/gtkgensurf/gensurf.cpp

index 044f43c..038d93a 100644 (file)
@@ -77,86 +77,89 @@ void GenerateBitmapMapping ()
 
 static unsigned char* OpenBitmapFile ()
 {
-  int bmWidth;
-  int bmHeight;
-  unsigned char bmPlanes;
-  unsigned char bmBitsPixel;
-  unsigned char m1,m2;
-  unsigned long sizeimage;
-  short res1,res2;
-  long filesize, pixoff;
-  long bmisize, compression;
-  long xscale, yscale;
-  long colors, impcol;
-  unsigned long m_bytesRead = 0;
+#define INVALID_FORMAT do{\
+  fprintf(stderr,"%s:%d: Error file '%s' is malformed.\n",__FILE__,__LINE__,gbmp.name);\
+  fclose(fp);\
+  return NULL;\
+}while(0);
+
+  int32_t bmWidth;
+  int32_t bmHeight;
+  uint16_t bmPlanes;
+  uint16_t bmBitsPixel;
+  uint8_t m1,m2;
+  uint32_t sizeimage;
+  int16_t res1,res2;
+  int32_t filesize, pixoff;
+  int32_t bmisize, compression;
+  int32_t xscale, yscale;
+  int32_t colors, impcol;
+  uint32_t m_bytesRead = 0;
   unsigned char *image;
   FILE *fp;
 
   fp = fopen (gbmp.name, "rb");
   if (fp == NULL)
-    return NULL;
+  {
+         fprintf(stderr,"Error: Invalid filename '%s'\n",gbmp.name);
+         return NULL;
+  }
 
   long rc;
   rc = fread(&m1, 1, 1, fp);
   m_bytesRead++;
   if (rc == -1)
-  {
-    fclose(fp);
-    return NULL;
-  }
+  INVALID_FORMAT;
 
   rc = fread(&m2, 1, 1, fp);
   m_bytesRead++;
   if ((m1 != 'B') || (m2 != 'M'))
-  {
-    fclose(fp);
-    return NULL;
-  }
+  INVALID_FORMAT;
 
-  rc = fread((long*)&(filesize),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(filesize),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(res1),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(res1),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(res2),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(res2),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(pixoff),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(pixoff),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(bmisize),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(bmisize),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long  *)&(bmWidth),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t  *)&(bmWidth),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(bmHeight),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(bmHeight),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(bmPlanes),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(bmPlanes),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(bmBitsPixel),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(bmBitsPixel),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(compression),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(compression),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(sizeimage),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) {fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(sizeimage),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(xscale),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(xscale),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(yscale),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(yscale),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(colors),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(colors),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(impcol),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(impcol),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
   if (bmBitsPixel != 8)
   {
@@ -180,40 +183,35 @@ static unsigned char* OpenBitmapFile ()
       m_bytesRead++;
       if (rc!=1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&g, 1, 1, fp); 
       m_bytesRead++;
       if (rc!=1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&r, 1, 1, fp); 
       m_bytesRead++;
       if (rc != 1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&dummy, 1, 1, fp); 
       m_bytesRead++;
       if (rc != 1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
     }
   }
 
   if ((long)m_bytesRead > pixoff)
   {
-    fclose(fp);
-    return NULL;
+          INVALID_FORMAT;
   }
 
   while ((long)m_bytesRead < pixoff)
@@ -231,8 +229,6 @@ static unsigned char* OpenBitmapFile ()
 
   if (image != NULL) 
   {
-    gbmp.width = w;
-    gbmp.height = h;
     unsigned char* outbuf = image;
     long row = 0;
     long rowOffset = 0;
@@ -261,8 +257,7 @@ static unsigned char* OpenBitmapFile ()
               if (fread(&inbyte,1,1,fp) != 1)
               {
                 free(image);
-                fclose(fp);
-                return NULL;
+                INVALID_FORMAT;
               }
               m_bytesRead++;
             }
@@ -283,8 +278,7 @@ static unsigned char* OpenBitmapFile ()
             if (fread(&dummy,1,1,fp)!=1)
             {
               free(image);
-              fclose(fp);
-              return NULL;
+              INVALID_FORMAT;
             }
             m_bytesRead++;
           }
@@ -402,15 +396,21 @@ static unsigned char* OpenBitmapFile ()
     }
   }
   fclose(fp);
+
+  gbmp.width = w;
+  gbmp.height = h;
+  if(gbmp.colors)
+       free(gbmp.colors);
+  gbmp.colors = image;
   return image;
+
+
 }
 
 bool OpenBitmap ()
 {
-  if (gbmp.colors)
-    free (gbmp.colors);
 
-  gbmp.colors = OpenBitmapFile ();
+  OpenBitmapFile ();
 
   if (!gbmp.colors)
   {
index 5055c03..cc9083d 100644 (file)
@@ -47,7 +47,7 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
        int Bisect(NODE *, int, int, int);
        void CalcAngles(NODE *, int *, float *);
        void EdgeOnSide(int *, int *, int *);
-       int tricall(int, NODE *, int *, TRI **, TRI **, char *);
+       int tricall(int, NODE *, int *, TRI **, TRI **, const char *);
        int CheckBorders(int *,int,NODE *,int *,TRI **);
 
        float       biggesterror;
@@ -195,7 +195,7 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
                        Tri = *pTri;
                        // Sliver-check along borders. Since borders are often linear, the errors
                        // along borders will often be zero, so no new points will be added. This
-                       // tends to produce long, thin brushes. For all border triangles, check 
+                       // tends to produce long, thin brushes. For all border triangles, check
                        // that minimum angle isn't less than SLIVER_ANGLE. If it is, add another
                        // vertex.
                        while(CheckBorders(&NumNodesUsed,NumNodes[0],Node,NumTris,pTri) > 0)
@@ -323,9 +323,8 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
 /*  tricall Takes an array of nodes, spits out an array of triangles         */
 /*                                                                           */
 /*****************************************************************************/
-int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, LPSTR Options)
+int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, const char *Options)
 {
-
        struct triangulateio in, out;
        int    i, N;
        int    NumUsedNodes;
@@ -426,18 +425,18 @@ int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, LPST
 
        /* Make necessary initializations */
        out.pointlist          = (REAL *) NULL;  /* Not needed if -N switch used. */
-       out.pointattributelist = (REAL *) NULL;  /* Not needed if -N switch used or 
+       out.pointattributelist = (REAL *) NULL;  /* Not needed if -N switch used or
                                                    number of point attributes is zero: */
        out.pointmarkerlist    = (int *) NULL;   /* Not needed if -N or -B switch used. */
        out.trianglelist       = (int *) NULL;   /* Not needed if -E switch used. */
-       out.triangleattributelist = (REAL *) NULL;   /* Not needed if -E switch used or 
-                                                       number of triangle attributes is 
+       out.triangleattributelist = (REAL *) NULL;   /* Not needed if -E switch used or
+                                                       number of triangle attributes is
                                                     zero: */
        out.trianglearealist   = (REAL *) NULL;
        out.neighborlist       = (int *) NULL;   /* Needed only if -n switch used. */
-       out.segmentlist        = (int *) NULL;   /* Needed only if segments are output 
+       out.segmentlist        = (int *) NULL;   /* Needed only if segments are output
                                                    (-p or -c) and -P not used: */
-       out.segmentmarkerlist  = (int *) NULL;   /* Needed only if segments are output 
+       out.segmentmarkerlist  = (int *) NULL;   /* Needed only if segments are output
                                                    (-p or -c) and -P and -B not used: */
        out.edgelist           = (int *) NULL;   /* Needed only if -e switch used. */
        out.edgemarkerlist     = (int *) NULL;   /* Needed if -e used and -B not used. */
@@ -715,7 +714,7 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                if(UseDetail) contents += CONTENTS_DETAIL;
                if(UseLadder) contents += CONTENTS_LADDER;
        }
-       
+
        OpenFuncGroup();
        for(i=0; i<NumTris; i++)
        {
@@ -725,11 +724,11 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                brush.face[0].v[0][0] = Node[Tri[i].v[0]].p[0];
                brush.face[0].v[0][1] = Node[Tri[i].v[0]].p[1];
                brush.face[0].v[0][2] = Node[Tri[i].v[0]].p[2];
-               
+
                brush.face[0].v[1][0] = Node[Tri[i].v[2]].p[0];
                brush.face[0].v[1][1] = Node[Tri[i].v[2]].p[1];
                brush.face[0].v[1][2] = Node[Tri[i].v[2]].p[2];
-               
+
                brush.face[0].v[2][0] = Node[Tri[i].v[1]].p[0];
                brush.face[0].v[2][1] = Node[Tri[i].v[1]].p[1];
                brush.face[0].v[2][2] = Node[Tri[i].v[1]].p[2];
@@ -778,50 +777,50 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[1].v[0][1] = (float)backface;
                        brush.face[1].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[1].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[1].v[1][1] = (float)backface;
                        brush.face[1].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[1].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[1].v[2][1] = (float)backface;
                        brush.face[1].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[2][1] = (float)backface;
                        brush.face[2].v[2][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[2][1] = (float)backface;
                        brush.face[3].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[2][1] = (float)backface;
                        brush.face[4].v[2][2] = Node[Tri[i].v[0]].p[2];
@@ -832,50 +831,50 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = (float)backface;
                        brush.face[1].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[1].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[1].v[1][0] = (float)backface;
                        brush.face[1].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[1].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[1].v[2][0] = (float)backface;
                        brush.face[1].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[1].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = (float)backface;
                        brush.face[2].v[2][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[2][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = (float)backface;
                        brush.face[3].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = (float)backface;
                        brush.face[4].v[2][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[2][2] = Node[Tri[i].v[0]].p[2];
@@ -885,55 +884,55 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[1].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[1].v[0][2] = (float)backface;
-                       
+
                        brush.face[1].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[1].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[1].v[1][2] = (float)backface;
-                       
+
                        brush.face[1].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[1].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[1].v[2][2] = (float)backface;
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[2][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[2][2] = (float)backface;
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[2][2] = (float)backface;
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[2][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[2][2] = (float)backface;
                }
-               
+
                for(j=0; j<5; j++)
                {
                        strcpy(brush.face[j].texture,
@@ -1052,10 +1051,10 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                default:
                        front  = MoreThan(zmax,32.);
                }
-               
+
                for(i=0; i<NumTris; i++)
                        Tri[i].flag = 0;
-               
+
                switch(Plane)
                {
                case PLANE_XZ0:
@@ -1075,7 +1074,7 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                        j1 = 0;
                        j2 = 1;
                }
-               
+
                brush.Number = 0;
                brush.NumFaces = 6;
                MaxHints = NH*NV-1;
@@ -1131,41 +1130,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = Node[q[2]].p[0];
                                                        brush.face[0].v[0][1] = (float)front;
                                                        brush.face[0].v[0][2] = Node[q[2]].p[2];
-                                                       
+
                                                        brush.face[0].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[0].v[1][1] = (float)front;
                                                        brush.face[0].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[0].v[2][0] = Node[q[0]].p[0];
                                                        brush.face[0].v[2][1] = (float)front;
                                                        brush.face[0].v[2][2] = Node[q[0]].p[2];
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = Node[q[0]].p[0];
                                                        brush.face[1].v[0][1] = (float)backface;
                                                        brush.face[1].v[0][2] = Node[q[0]].p[2];
-                                                       
+
                                                        brush.face[1].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[1].v[1][1] = (float)backface;
                                                        brush.face[1].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[1].v[2][0] = Node[q[2]].p[0];
                                                        brush.face[1].v[2][1] = (float)backface;
                                                        brush.face[1].v[2][2] = Node[q[2]].p[2];
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = Node[q[k0]].p[0];
                                                                brush.face[k].v[0][1] = (float)front;
                                                                brush.face[k].v[0][2] = Node[q[k0]].p[2];
-                                                               
+
                                                                brush.face[k].v[1][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[1][1] = (float)front;
                                                                brush.face[k].v[1][2] = Node[q[k1]].p[2];
-                                                               
+
                                                                brush.face[k].v[2][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[2][1] = (float)backface;
                                                                brush.face[k].v[2][2] = Node[q[k1]].p[2];
@@ -1177,41 +1176,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = (float)front;
                                                        brush.face[0].v[0][1] = Node[q[2]].p[1];
                                                        brush.face[0].v[0][2] = Node[q[2]].p[2];
-                                                       
+
                                                        brush.face[0].v[1][0] = (float)front;
                                                        brush.face[0].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[0].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[0].v[2][0] = (float)front;
                                                        brush.face[0].v[2][1] = Node[q[0]].p[1];
                                                        brush.face[0].v[2][2] = Node[q[0]].p[2];
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = (float)backface;
                                                        brush.face[1].v[0][1] = Node[q[0]].p[1];
                                                        brush.face[1].v[0][2] = Node[q[0]].p[2];
-                                                       
+
                                                        brush.face[1].v[1][0] = (float)backface;
                                                        brush.face[1].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[1].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[1].v[2][0] = (float)backface;
                                                        brush.face[1].v[2][1] = Node[q[2]].p[1];
                                                        brush.face[1].v[2][2] = Node[q[2]].p[2];
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = (float)front;
                                                                brush.face[k].v[0][1] = Node[q[k0]].p[1];
                                                                brush.face[k].v[0][2] = Node[q[k0]].p[2];
-                                                               
+
                                                                brush.face[k].v[1][0] = (float)front;
                                                                brush.face[k].v[1][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[1][2] = Node[q[k1]].p[2];
-                                                               
+
                                                                brush.face[k].v[2][0] = (float)backface;
                                                                brush.face[k].v[2][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[2][2] = Node[q[k1]].p[2];
@@ -1222,41 +1221,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = Node[q[2]].p[0];
                                                        brush.face[0].v[0][1] = Node[q[2]].p[1];
                                                        brush.face[0].v[0][2] = (float)front;
-                                                       
+
                                                        brush.face[0].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[0].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[0].v[1][2] = (float)front;
-                                                       
+
                                                        brush.face[0].v[2][0] = Node[q[0]].p[0];
                                                        brush.face[0].v[2][1] = Node[q[0]].p[1];
                                                        brush.face[0].v[2][2] = (float)front;
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = Node[q[0]].p[0];
                                                        brush.face[1].v[0][1] = Node[q[0]].p[1];
                                                        brush.face[1].v[0][2] = (float)backface;
-                                                       
+
                                                        brush.face[1].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[1].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[1].v[1][2] = (float)backface;
-                                                       
+
                                                        brush.face[1].v[2][0] = Node[q[2]].p[0];
                                                        brush.face[1].v[2][1] = Node[q[2]].p[1];
                                                        brush.face[1].v[2][2] = (float)backface;
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = Node[q[k0]].p[0];
                                                                brush.face[k].v[0][1] = Node[q[k0]].p[1];
                                                                brush.face[k].v[0][2] = (float)front;
-                                                               
+
                                                                brush.face[k].v[1][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[1][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[1][2] = (float)front;
-                                                               
+
                                                                brush.face[k].v[2][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[2][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[2][2] = (float)backface;
index dabb72d..c31741d 100644 (file)
@@ -176,7 +176,7 @@ void texfont_init ()
 
   int i, j, x, y;
   float inv = 1.0f/128;
-  char *charlines[16] = { 
+  const char *charlines[16] = { 
     "abcdefghijklmn", "opqrstuvwxyz0", "123456789ABC", "DEFGHIJKLMN", 
     "OPQRSTUVWX", "YZ,.!;:<>/?{}@$%", "&*()-+=_[] #" };
   unsigned char lefts[7][17] = { 
index 9481570..dcda98a 100644 (file)
@@ -890,11 +890,6 @@ static gint bitmap_file_entryfocusout(GtkWidget* widget, GdkEventFocus* event, g
   strcpy (filename, gtk_entry_get_text (GTK_ENTRY(widget)));
   if(strcmp (filename,gbmp.name))
   {
-    if (gbmp.colors)
-    {
-      free(gbmp.colors);
-      gbmp.colors=NULL;
-    }
     strcpy (gbmp.name,filename);
     if (strlen(gbmp.name) )
       OpenBitmap ();
@@ -1389,10 +1384,10 @@ GtkWidget* create_main_dialog ()
   GtkObject *adj;
   GSList *group;
   int i;
-  char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" };
-  char *waveforms[] = { "Alternating hill/valley", "Cylindrical left-to-right", "Cylindrical top-to-bottom",
+  const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" };
+  const char *waveforms[] = { "Alternating hill/valley", "Cylindrical left-to-right", "Cylindrical top-to-bottom",
                         "From bitmap", "Fractal" };
-  char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
+  const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
                            "Wall facing 180","Wall facing 270" }; 
 
   g_pWnd = dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
index 32b54b5..3c3107a 100644 (file)
@@ -133,11 +133,12 @@ bool GenSurfInit ()
   else */
     Game = QUAKE3;
 
-  ReadIniFile (gszIni);
 
   if (g_pWnd == NULL)
     g_pWnd = create_main_dialog ();
 
+  ReadIniFile (gszIni);
+
   return true;
 }
 
@@ -291,9 +292,10 @@ void ReadIniFile (const char *file)
   if(!strlen(Texture[GENESIS3D][0])) strcpy(Texture[GENESIS3D][0],"textures/rock13");
   if(!strlen(Texture[QUAKE3][0]))    strcpy(Texture[QUAKE3][0],   "textures/organics/grass3");
   if(!strlen(Texture[QUAKE3][1]))    strcpy(Texture[QUAKE3][1],   "textures/common/caulk");
-
   strcpy (gbmp.name, g_FuncTable.m_pfnProfileLoadString (file, "Bitmap","Filename",""));
 
+
+  gbmp.colors = NULL;
   if (strlen(gbmp.name))
     OpenBitmap ();
 
@@ -321,7 +323,7 @@ varargs versions of all text functions.
 FIXME: make this buffer size safe someday
 ============
 */
-char *va (char *format, ...)
+char *va (const char *format, ...)
 {
   va_list argptr;
   static char string[1024];