]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/gtkgensurf/heretic.cpp
Revert partially (auto) "reformat code! now the code is only ugly on the *inside*"
[xonotic/netradiant.git] / contrib / gtkgensurf / heretic.cpp
index a6fc5693da2a93246b9980342c61a09352766b1e..e07a378b6270a141876e65f954e4719fa8e7dd25 100644 (file)
 
 // Heretic 2 - specific routines
 
-typedef struct palette_s {
-    guint8 r, g, b;
+typedef struct palette_s
+{
+       guint8 r,g,b;
 } palette_t;
 
 #define MIP_VERSION     2
 #define PAL_SIZE        256
 #define MIPLEVELS       16
 
-typedef struct miptex_s {
-    int version;
-    char name[32];
-    unsigned width[MIPLEVELS], height[MIPLEVELS];
-    unsigned offsets[MIPLEVELS];        // four mip maps stored
-    char animname[32];                  // next frame in animation chain
-    palette_t palette[PAL_SIZE];
-    int flags;
-    int contents;
-    int value;
+typedef struct miptex_s
+{
+       int version;
+       char name[32];
+       unsigned width[MIPLEVELS], height[MIPLEVELS];
+       unsigned offsets[MIPLEVELS];        // four mip maps stored
+       char animname[32];                  // next frame in animation chain
+       palette_t palette[PAL_SIZE];
+       int flags;
+       int contents;
+       int value;
 } miptex_t;
 
 //=============================================================
-int GetDefSurfaceProps(char *Tex)
-{
-    return 0; // leo: only used for Heretic 2, fix later
-    /*
-       char            path[NAME_MAX];
-       char        *p;
-       int         flags;
-       miptex_t        *mt;
-       FILE        *f;
-       int         length;
-       int         pos;
+int GetDefSurfaceProps( char *Tex ){
+       return 0; // leo: only used for Heretic 2, fix later
+       /*
+          char         path[NAME_MAX];
+          char        *p;
+          int         flags;
+          miptex_t     *mt;
+          FILE     *f;
+          int         length;
+          int         pos;
 
-       if(Game != HERETIC2) return 0;
-       if(!strlen(Tex)) return 0;
+          if(Game != HERETIC2) return 0;
+          if(!strlen(Tex)) return 0;
 
-       mt = NULL;
-       flags = 0;
-       if(UsePak[Game])
-       {
-          FILE         *fpak;
-          pak_header_t pakheader;
-          pak_item_t   pakitem;
-          int          i;
-          int          num;
-          int          numitems;
+          mt = NULL;
+          flags = 0;
+          if(UsePak[Game])
+          {
+             FILE         *fpak;
+             pak_header_t pakheader;
+             pak_item_t   pakitem;
+             int          i;
+             int          num;
+             int          numitems;
 
-          if (NULL != (fpak = fopen(pakfile[Game], "rb")))
-          {
-              sprintf(path,"textures/%s.m8",Tex);
-              g_strdown(path);
-              num=fread(&pakheader,1,sizeof(pak_header_t),fpak);
-              if((size_t)num < sizeof(pak_header_t))
-              {
-                  fclose(fpak);
-                  return 0;
-              }
-              if(strncmp(pakheader.id,"PACK",4))
-              {
-                  fclose(fpak);
-                  return 0;
-              }
-              numitems = pakheader.dsize/sizeof(pak_item_t);
-              fseek(fpak,pakheader.dstart,SEEK_SET);
-              for(i=0; i<numitems; i++)
-              {
-                  fread(&pakitem,1,sizeof(pak_item_t),fpak);
-                  if(strstr(pakitem.name,path))
-                  {
-                      fseek(fpak,pakitem.start,SEEK_SET);
-                      if((mt = (miptex_t*)malloc(sizeof(miptex_t)))==NULL)
-                      {
-                          fclose(fpak);
-                          return 0;
-                      }
-                      else
-                      {
-                          fread(mt, 1, sizeof(miptex_t), fpak);
-                          flags = mt->flags;
-                          free(mt);
-                      }
-                  }
-              }
-              fclose(fpak);
-          }
-       }
-       else
-       {
-          // Assume .map will be output to gamedir/maps, then back up
-          // to the gamedir and append /textures. Ugly but it should work
-          strcpy(path,gszMapFile);
-          g_strdown(path);
-          p = strstr(path,"maps");
-          if(!p) return 0;
-          p[0] = '\0';
-          strcat(path,"textures/");
-          strcat(path,Tex);
-          strcat(path,".m8");
-          f = fopen (path, "rb");
-          if (!f)
-              flags = 0;
-          else
-          {
-              pos = ftell (f);
-              fseek (f, 0, SEEK_END);
-              length = ftell (f);
-              fseek (f, pos, SEEK_SET);
-              if((mt = (miptex_t*)malloc(length+1))==NULL)
-                  flags = 0;
-              else
-              {
-                  ((char *)mt)[length] = 0;
-                  fread(mt, 1, length, f);
-                  fclose (f);
-                  flags = mt->flags;
-                  free(mt);
-              }
-          }
-       }
-       return flags;
-     */
+             if (NULL != (fpak = fopen(pakfile[Game], "rb")))
+             {
+                 sprintf(path,"textures/%s.m8",Tex);
+                 g_strdown(path);
+                 num=fread(&pakheader,1,sizeof(pak_header_t),fpak);
+                 if((size_t)num < sizeof(pak_header_t))
+                 {
+                     fclose(fpak);
+                     return 0;
+                 }
+                 if(strncmp(pakheader.id,"PACK",4))
+                 {
+                     fclose(fpak);
+                     return 0;
+                 }
+                 numitems = pakheader.dsize/sizeof(pak_item_t);
+                 fseek(fpak,pakheader.dstart,SEEK_SET);
+                 for(i=0; i<numitems; i++)
+                 {
+                     fread(&pakitem,1,sizeof(pak_item_t),fpak);
+                     if(strstr(pakitem.name,path))
+                     {
+                         fseek(fpak,pakitem.start,SEEK_SET);
+                         if((mt = (miptex_t*)malloc(sizeof(miptex_t)))==NULL)
+                         {
+                             fclose(fpak);
+                             return 0;
+                         }
+                         else
+                         {
+                             fread(mt, 1, sizeof(miptex_t), fpak);
+                             flags = mt->flags;
+                             free(mt);
+                         }
+                     }
+                 }
+                 fclose(fpak);
+             }
+          }
+          else
+          {
+             // Assume .map will be output to gamedir/maps, then back up
+             // to the gamedir and append /textures. Ugly but it should work
+             strcpy(path,gszMapFile);
+             g_strdown(path);
+             p = strstr(path,"maps");
+             if(!p) return 0;
+             p[0] = '\0';
+             strcat(path,"textures/");
+             strcat(path,Tex);
+             strcat(path,".m8");
+             f = fopen (path, "rb");
+             if (!f)
+                 flags = 0;
+             else
+             {
+                 pos = ftell (f);
+                 fseek (f, 0, SEEK_END);
+                 length = ftell (f);
+                 fseek (f, pos, SEEK_SET);
+                 if((mt = (miptex_t*)malloc(length+1))==NULL)
+                     flags = 0;
+                 else
+                 {
+                     ((char *)mt)[length] = 0;
+                     fread(mt, 1, length, f);
+                     fclose (f);
+                     flags = mt->flags;
+                     free(mt);
+                 }
+             }
+          }
+          return flags;
+        */
 }