2 GenSurf plugin for GtkRadiant
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
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.
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.
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
25 // Heretic 2 - specific routines
27 typedef struct palette_s
36 typedef struct miptex_s
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];
49 //=============================================================
50 int GetDefSurfaceProps( char *Tex ){
51 return 0; // leo: only used for Heretic 2, fix later
61 if(Game != HERETIC2) return 0;
62 if(!strlen(Tex)) return 0;
69 pak_header_t pakheader;
75 if (NULL != (fpak = fopen(pakfile[Game], "rb")))
77 sprintf(path,"textures/%s.m8",Tex);
79 num=fread(&pakheader,1,sizeof(pak_header_t),fpak);
80 if((size_t)num < sizeof(pak_header_t))
85 if(strncmp(pakheader.id,"PACK",4))
90 numitems = pakheader.dsize/sizeof(pak_item_t);
91 fseek(fpak,pakheader.dstart,SEEK_SET);
92 for(i=0; i<numitems; i++)
94 fread(&pakitem,1,sizeof(pak_item_t),fpak);
95 if(strstr(pakitem.name,path))
97 fseek(fpak,pakitem.start,SEEK_SET);
98 if((mt = (miptex_t*)malloc(sizeof(miptex_t)))==NULL)
105 fread(mt, 1, sizeof(miptex_t), fpak);
116 // Assume .map will be output to gamedir/maps, then back up
117 // to the gamedir and append /textures. Ugly but it should work
118 strcpy(path,gszMapFile);
120 p = strstr(path,"maps");
123 strcat(path,"textures/");
126 f = fopen (path, "rb");
132 fseek (f, 0, SEEK_END);
134 fseek (f, pos, SEEK_SET);
135 if((mt = (miptex_t*)malloc(length+1))==NULL)
139 ((char *)mt)[length] = 0;
140 fread(mt, 1, length, f);