]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - misc/mediasource/extra/netradiant-src/contrib/gtkgensurf/heretic.cpp
Rename the compiled fteqcc to fteqcc-win32 (as that's what it is)
[voretournament/voretournament.git] / misc / mediasource / extra / netradiant-src / contrib / gtkgensurf / heretic.cpp
1 /*
2 GenSurf plugin for GtkRadiant
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #include <stdlib.h>
21 #include <math.h>
22 #include <stdio.h>
23 #include "gensurf.h"
24
25 // Heretic 2 - specific routines
26
27 typedef struct palette_s
28 {
29   guint8 r,g,b;
30 } palette_t;
31
32 #define MIP_VERSION             2
33 #define PAL_SIZE                256
34 #define MIPLEVELS               16
35
36 typedef struct miptex_s
37 {
38         int                     version;
39         char            name[32];
40         unsigned        width[MIPLEVELS], height[MIPLEVELS];
41         unsigned        offsets[MIPLEVELS];             // four mip maps stored
42         char            animname[32];                   // next frame in animation chain
43         palette_t       palette[PAL_SIZE];
44         int                     flags;
45         int                     contents;
46         int                     value;
47 } miptex_t;
48
49 //=============================================================
50 int GetDefSurfaceProps(char *Tex)
51 {
52   return 0; // leo: only used for Heretic 2, fix later
53   /*
54         char            path[NAME_MAX];
55         char        *p;
56         int         flags;
57         miptex_t        *mt;
58         FILE        *f;
59         int         length;
60         int         pos;
61
62         if(Game != HERETIC2) return 0;
63         if(!strlen(Tex)) return 0;
64
65         mt = NULL;
66         flags = 0;
67         if(UsePak[Game])
68         {
69                 FILE         *fpak;
70                 pak_header_t pakheader;
71                 pak_item_t   pakitem;
72                 int          i;
73                 int          num;
74                 int          numitems;
75
76                 if (NULL != (fpak = fopen(pakfile[Game], "rb")))
77                 {
78                         sprintf(path,"textures/%s.m8",Tex);
79                         g_strdown(path);
80                         num=fread(&pakheader,1,sizeof(pak_header_t),fpak);
81                         if((size_t)num < sizeof(pak_header_t))
82                         {
83                                 fclose(fpak);
84                                 return 0;
85                         }
86                         if(strncmp(pakheader.id,"PACK",4))
87                         {
88                                 fclose(fpak);
89                                 return 0;
90                         }
91                         numitems = pakheader.dsize/sizeof(pak_item_t);
92                         fseek(fpak,pakheader.dstart,SEEK_SET);
93                         for(i=0; i<numitems; i++)
94                         {
95                                 fread(&pakitem,1,sizeof(pak_item_t),fpak);
96                                 if(strstr(pakitem.name,path))
97                                 {
98                                         fseek(fpak,pakitem.start,SEEK_SET);
99                                         if((mt = (miptex_t*)malloc(sizeof(miptex_t)))==NULL)
100                                         {
101                                                 fclose(fpak);
102                                                 return 0;
103                                         }
104                                         else
105                                         {
106                                                 fread(mt, 1, sizeof(miptex_t), fpak);
107                                                 flags = mt->flags;
108                                                 free(mt);
109                                         }
110                                 }
111                         }
112                         fclose(fpak);
113                 }
114         }
115         else
116         {
117                 // Assume .map will be output to gamedir/maps, then back up
118                 // to the gamedir and append /textures. Ugly but it should work
119                 strcpy(path,gszMapFile);
120                 g_strdown(path);
121                 p = strstr(path,"maps");
122                 if(!p) return 0;
123                 p[0] = '\0';
124                 strcat(path,"textures/");
125                 strcat(path,Tex);
126                 strcat(path,".m8");
127                 f = fopen (path, "rb");
128                 if (!f)
129                         flags = 0;
130                 else
131                 {
132                         pos = ftell (f);
133                         fseek (f, 0, SEEK_END);
134                         length = ftell (f);
135                         fseek (f, pos, SEEK_SET);
136                         if((mt = (miptex_t*)malloc(length+1))==NULL)
137                                 flags = 0;
138                         else
139                         {
140                                 ((char *)mt)[length] = 0;
141                                 fread(mt, 1, length, f);
142                                 fclose (f);
143                                 flags = mt->flags;
144                                 free(mt);
145                         }
146                 }
147         }
148         return flags;
149   */
150 }