mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
rewrite bspfile.[ch] so they work off an object rather than global data.
The direct filesystem access is also removed. Fix up qfvis and qflight to compile with the new bspfile. qfvis seems to work, qflight probably doesn't
This commit is contained in:
parent
86f542a971
commit
24a9b48127
10 changed files with 285 additions and 308 deletions
|
@ -29,6 +29,7 @@
|
||||||
#define __bspfile_h_
|
#define __bspfile_h_
|
||||||
|
|
||||||
#include "QF/qtypes.h"
|
#include "QF/qtypes.h"
|
||||||
|
#include "QF/quakeio.h"
|
||||||
|
|
||||||
// upper design bounds
|
// upper design bounds
|
||||||
|
|
||||||
|
@ -231,59 +232,55 @@ typedef struct {
|
||||||
#define ANGLE_UP -1
|
#define ANGLE_UP -1
|
||||||
#define ANGLE_DOWN -2
|
#define ANGLE_DOWN -2
|
||||||
|
|
||||||
// the utilities get to be lazy and just use large static arrays
|
typedef struct bsp_s {
|
||||||
|
int nummodels;
|
||||||
|
dmodel_t *models;
|
||||||
|
|
||||||
extern int nummodels;
|
int visdatasize;
|
||||||
extern dmodel_t *dmodels;
|
byte *visdata;
|
||||||
|
|
||||||
extern int visdatasize;
|
int lightdatasize;
|
||||||
extern byte *dvisdata;
|
byte *lightdata;
|
||||||
|
|
||||||
extern int lightdatasize;
|
int texdatasize;
|
||||||
extern byte *dlightdata;
|
byte *texdata; // (dmiptexlump_t)
|
||||||
|
|
||||||
extern int texdatasize;
|
int entdatasize;
|
||||||
extern byte *dtexdata; // (dmiptexlump_t)
|
char *entdata;
|
||||||
|
|
||||||
extern int entdatasize;
|
int numleafs;
|
||||||
extern char *dentdata;
|
dleaf_t *leafs;
|
||||||
|
|
||||||
extern int numleafs;
|
int numplanes;
|
||||||
extern dleaf_t *dleafs;
|
dplane_t *planes;
|
||||||
|
|
||||||
extern int numplanes;
|
int numvertexes;
|
||||||
extern dplane_t *dplanes;
|
dvertex_t *vertexes;
|
||||||
|
|
||||||
extern int numvertexes;
|
int numnodes;
|
||||||
extern dvertex_t *dvertexes;
|
dnode_t *nodes;
|
||||||
|
|
||||||
extern int numnodes;
|
int numtexinfo;
|
||||||
extern dnode_t *dnodes;
|
texinfo_t *texinfo;
|
||||||
|
|
||||||
extern int numtexinfo;
|
int numfaces;
|
||||||
extern texinfo_t *texinfo;
|
dface_t *faces;
|
||||||
|
|
||||||
extern int numfaces;
|
int numclipnodes;
|
||||||
extern dface_t *dfaces;
|
dclipnode_t *clipnodes;
|
||||||
|
|
||||||
extern int numclipnodes;
|
int numedges;
|
||||||
extern dclipnode_t *dclipnodes;
|
dedge_t *edges;
|
||||||
|
|
||||||
extern int numedges;
|
int nummarksurfaces;
|
||||||
extern dedge_t *dedges;
|
unsigned short *marksurfaces;
|
||||||
|
|
||||||
extern int nummarksurfaces;
|
int numsurfedges;
|
||||||
extern unsigned short *dmarksurfaces;
|
int *surfedges;
|
||||||
|
} bsp_t;
|
||||||
|
|
||||||
extern int numsurfedges;
|
bsp_t *LoadBSPFile (QFile *file, int size);
|
||||||
extern int *dsurfedges;
|
void WriteBSPFile (bsp_t *bsp, QFile *file);
|
||||||
|
|
||||||
void DecompressVis (byte *in, byte *decompressed);
|
|
||||||
int CompressVis (byte *vis, byte *dest);
|
|
||||||
|
|
||||||
void LoadBSPFile (const char *filename);
|
|
||||||
void WriteBSPFile (const char *filename);
|
|
||||||
void PrintBSPFileSizes (void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif // __bspfile_h_
|
#endif // __bspfile_h_
|
||||||
|
|
|
@ -49,248 +49,178 @@ static const char rcsid[] =
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
int nummodels;
|
|
||||||
dmodel_t *dmodels;
|
|
||||||
|
|
||||||
int visdatasize;
|
|
||||||
byte *dvisdata;
|
|
||||||
|
|
||||||
int lightdatasize;
|
|
||||||
byte *dlightdata;
|
|
||||||
|
|
||||||
int texdatasize;
|
|
||||||
byte *dtexdata;
|
|
||||||
|
|
||||||
int entdatasize;
|
|
||||||
char *dentdata;
|
|
||||||
|
|
||||||
int numleafs;
|
|
||||||
dleaf_t *dleafs;
|
|
||||||
|
|
||||||
int numplanes;
|
|
||||||
dplane_t *dplanes;
|
|
||||||
|
|
||||||
int numvertexes;
|
|
||||||
dvertex_t *dvertexes;
|
|
||||||
|
|
||||||
int numnodes;
|
|
||||||
dnode_t *dnodes;
|
|
||||||
|
|
||||||
int numtexinfo;
|
|
||||||
texinfo_t *texinfo;
|
|
||||||
|
|
||||||
int numfaces;
|
|
||||||
dface_t *dfaces;
|
|
||||||
|
|
||||||
int numclipnodes;
|
|
||||||
dclipnode_t *dclipnodes;
|
|
||||||
|
|
||||||
int numedges;
|
|
||||||
dedge_t *dedges;
|
|
||||||
|
|
||||||
int nummarksurfaces;
|
|
||||||
unsigned short *dmarksurfaces;
|
|
||||||
|
|
||||||
int numsurfedges;
|
|
||||||
int *dsurfedges;
|
|
||||||
|
|
||||||
dheader_t *header;
|
|
||||||
dheader_t outheader;
|
|
||||||
QFile *wadfile;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
SwapBSPFile
|
|
||||||
|
|
||||||
Byte swaps all data in a bsp file.
|
|
||||||
*/
|
|
||||||
static void
|
static void
|
||||||
SwapBSPFile (qboolean todisk)
|
swap_bsp (bsp_t *bsp, int todisk)
|
||||||
{
|
{
|
||||||
int c, i, j;
|
int c, i, j;
|
||||||
dmiptexlump_t *mtl;
|
dmiptexlump_t *mtl;
|
||||||
dmodel_t *d;
|
dmodel_t *d;
|
||||||
|
|
||||||
// models
|
// models
|
||||||
for (i = 0; i < nummodels; i++) {
|
for (i=0 ; i<bsp->nummodels ; i++) {
|
||||||
d = &dmodels[i];
|
d = &bsp->models[i];
|
||||||
|
|
||||||
for (j = 0; j < MAX_MAP_HULLS; j++)
|
for (j=0 ; j<MAX_MAP_HULLS ; j++)
|
||||||
d->headnode[j] = LittleLong (d->headnode[j]);
|
d->headnode[j] = LittleLong (d->headnode[j]);
|
||||||
|
|
||||||
d->visleafs = LittleLong (d->visleafs);
|
d->visleafs = LittleLong (d->visleafs);
|
||||||
d->firstface = LittleLong (d->firstface);
|
d->firstface = LittleLong (d->firstface);
|
||||||
d->numfaces = LittleLong (d->numfaces);
|
d->numfaces = LittleLong (d->numfaces);
|
||||||
|
|
||||||
for (j = 0; j < 3; j++) {
|
for (j=0 ; j<3 ; j++) {
|
||||||
d->mins[j] = LittleFloat (d->mins[j]);
|
d->mins[j] = LittleFloat(d->mins[j]);
|
||||||
d->maxs[j] = LittleFloat (d->maxs[j]);
|
d->maxs[j] = LittleFloat(d->maxs[j]);
|
||||||
d->origin[j] = LittleFloat (d->origin[j]);
|
d->origin[j] = LittleFloat(d->origin[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vertexes
|
// vertexes
|
||||||
for (i = 0; i < numvertexes ; i++) {
|
for (i=0 ; i<bsp->numvertexes ; i++) {
|
||||||
for (j = 0; j < 3; j++)
|
for (j=0 ; j<3 ; j++)
|
||||||
dvertexes[i].point[j] = LittleFloat (dvertexes[i].point[j]);
|
bsp->vertexes[i].point[j] = LittleFloat (bsp->vertexes[i].point[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// planes
|
// planes
|
||||||
for (i = 0; i < numplanes; i++) {
|
for (i=0 ; i<bsp->numplanes ; i++) {
|
||||||
for (j = 0; j < 3; j++)
|
for (j=0 ; j<3 ; j++)
|
||||||
dplanes[i].normal[j] = LittleFloat (dplanes[i].normal[j]);
|
bsp->planes[i].normal[j] = LittleFloat (bsp->planes[i].normal[j]);
|
||||||
dplanes[i].dist = LittleFloat (dplanes[i].dist);
|
bsp->planes[i].dist = LittleFloat (bsp->planes[i].dist);
|
||||||
dplanes[i].type = LittleLong (dplanes[i].type);
|
bsp->planes[i].type = LittleLong (bsp->planes[i].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// texinfos
|
// texinfos
|
||||||
for (i = 0; i < numtexinfo; i++) {
|
for (i=0 ; i<bsp->numtexinfo ; i++) {
|
||||||
for (j = 0; j < 8; j++)
|
for (j=0 ; j<8 ; j++)
|
||||||
texinfo[i].vecs[0][j] = LittleFloat (texinfo[i].vecs[0][j]);
|
bsp->texinfo[i].vecs[0][j] = LittleFloat (bsp->texinfo[i].vecs[0][j]);
|
||||||
texinfo[i].miptex = LittleLong (texinfo[i].miptex);
|
bsp->texinfo[i].miptex = LittleLong (bsp->texinfo[i].miptex);
|
||||||
texinfo[i].flags = LittleLong (texinfo[i].flags);
|
bsp->texinfo[i].flags = LittleLong (bsp->texinfo[i].flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// faces
|
// faces
|
||||||
for (i = 0; i < numfaces; i++) {
|
for (i=0 ; i<bsp->numfaces ; i++) {
|
||||||
dfaces[i].texinfo = LittleShort (dfaces[i].texinfo);
|
bsp->faces[i].texinfo = LittleShort (bsp->faces[i].texinfo);
|
||||||
dfaces[i].planenum = LittleShort (dfaces[i].planenum);
|
bsp->faces[i].planenum = LittleShort (bsp->faces[i].planenum);
|
||||||
dfaces[i].side = LittleShort (dfaces[i].side);
|
bsp->faces[i].side = LittleShort (bsp->faces[i].side);
|
||||||
dfaces[i].lightofs = LittleLong (dfaces[i].lightofs);
|
bsp->faces[i].lightofs = LittleLong (bsp->faces[i].lightofs);
|
||||||
dfaces[i].firstedge = LittleLong (dfaces[i].firstedge);
|
bsp->faces[i].firstedge = LittleLong (bsp->faces[i].firstedge);
|
||||||
dfaces[i].numedges = LittleShort (dfaces[i].numedges);
|
bsp->faces[i].numedges = LittleShort (bsp->faces[i].numedges);
|
||||||
}
|
}
|
||||||
|
|
||||||
// nodes
|
// nodes
|
||||||
for (i = 0; i < numnodes; i++) {
|
for (i=0 ; i<bsp->numnodes ; i++) {
|
||||||
dnodes[i].planenum = LittleLong (dnodes[i].planenum);
|
bsp->nodes[i].planenum = LittleLong (bsp->nodes[i].planenum);
|
||||||
for (j = 0; j < 3; j++) {
|
for (j=0 ; j<3 ; j++) {
|
||||||
dnodes[i].mins[j] = LittleShort (dnodes[i].mins[j]);
|
bsp->nodes[i].mins[j] = LittleShort (bsp->nodes[i].mins[j]);
|
||||||
dnodes[i].maxs[j] = LittleShort (dnodes[i].maxs[j]);
|
bsp->nodes[i].maxs[j] = LittleShort (bsp->nodes[i].maxs[j]);
|
||||||
}
|
}
|
||||||
dnodes[i].children[0] = LittleShort (dnodes[i].children[0]);
|
bsp->nodes[i].children[0] = LittleShort (bsp->nodes[i].children[0]);
|
||||||
dnodes[i].children[1] = LittleShort (dnodes[i].children[1]);
|
bsp->nodes[i].children[1] = LittleShort (bsp->nodes[i].children[1]);
|
||||||
dnodes[i].firstface = LittleShort (dnodes[i].firstface);
|
bsp->nodes[i].firstface = LittleShort (bsp->nodes[i].firstface);
|
||||||
dnodes[i].numfaces = LittleShort (dnodes[i].numfaces);
|
bsp->nodes[i].numfaces = LittleShort (bsp->nodes[i].numfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
// leafs
|
// leafs
|
||||||
for (i = 0; i < numleafs; i++) {
|
for (i=0 ; i<bsp->numleafs ; i++) {
|
||||||
dleafs[i].contents = LittleLong (dleafs[i].contents);
|
bsp->leafs[i].contents = LittleLong (bsp->leafs[i].contents);
|
||||||
for (j = 0; j < 3; j++) {
|
for (j=0 ; j<3 ; j++) {
|
||||||
dleafs[i].mins[j] = LittleShort (dleafs[i].mins[j]);
|
bsp->leafs[i].mins[j] = LittleShort (bsp->leafs[i].mins[j]);
|
||||||
dleafs[i].maxs[j] = LittleShort (dleafs[i].maxs[j]);
|
bsp->leafs[i].maxs[j] = LittleShort (bsp->leafs[i].maxs[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dleafs[i].firstmarksurface = LittleShort (dleafs[i].firstmarksurface);
|
bsp->leafs[i].firstmarksurface = LittleShort (bsp->leafs[i].firstmarksurface);
|
||||||
dleafs[i].nummarksurfaces = LittleShort (dleafs[i].nummarksurfaces);
|
bsp->leafs[i].nummarksurfaces = LittleShort (bsp->leafs[i].nummarksurfaces);
|
||||||
dleafs[i].visofs = LittleLong (dleafs[i].visofs);
|
bsp->leafs[i].visofs = LittleLong (bsp->leafs[i].visofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clipnodes
|
// clipnodes
|
||||||
for (i = 0; i < numclipnodes; i++) {
|
for (i=0 ; i<bsp->numclipnodes ; i++) {
|
||||||
dclipnodes[i].planenum = LittleLong (dclipnodes[i].planenum);
|
bsp->clipnodes[i].planenum = LittleLong (bsp->clipnodes[i].planenum);
|
||||||
dclipnodes[i].children[0] = LittleShort (dclipnodes[i].children[0]);
|
bsp->clipnodes[i].children[0] = LittleShort (bsp->clipnodes[i].children[0]);
|
||||||
dclipnodes[i].children[1] = LittleShort (dclipnodes[i].children[1]);
|
bsp->clipnodes[i].children[1] = LittleShort (bsp->clipnodes[i].children[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// miptex
|
// miptex
|
||||||
if (texdatasize) {
|
if (bsp->texdatasize) {
|
||||||
mtl = (dmiptexlump_t *) dtexdata;
|
mtl = (dmiptexlump_t *)bsp->texdata;
|
||||||
if (todisk)
|
if (todisk)
|
||||||
c = mtl->nummiptex;
|
c = mtl->nummiptex;
|
||||||
else
|
else
|
||||||
c = LittleLong (mtl->nummiptex);
|
c = LittleLong(mtl->nummiptex);
|
||||||
mtl->nummiptex = LittleLong (mtl->nummiptex);
|
mtl->nummiptex = LittleLong (mtl->nummiptex);
|
||||||
for (i = 0; i < c; i++)
|
for (i=0 ; i<c ; i++)
|
||||||
mtl->dataofs[i] = LittleLong (mtl->dataofs[i]);
|
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// marksurfaces
|
// marksurfaces
|
||||||
for (i = 0; i < nummarksurfaces; i++)
|
for (i=0 ; i<bsp->nummarksurfaces ; i++)
|
||||||
dmarksurfaces[i] = LittleShort (dmarksurfaces[i]);
|
bsp->marksurfaces[i] = LittleShort (bsp->marksurfaces[i]);
|
||||||
|
|
||||||
// surfedges
|
// surfedges
|
||||||
for (i = 0; i < numsurfedges; i++)
|
for (i=0 ; i<bsp->numsurfedges ; i++)
|
||||||
dsurfedges[i] = LittleLong (dsurfedges[i]);
|
bsp->surfedges[i] = LittleLong (bsp->surfedges[i]);
|
||||||
|
|
||||||
// edges
|
// edges
|
||||||
for (i = 0; i < numedges; i++) {
|
for (i=0 ; i<bsp->numedges ; i++) {
|
||||||
dedges[i].v[0] = LittleShort (dedges[i].v[0]);
|
bsp->edges[i].v[0] = LittleShort (bsp->edges[i].v[0]);
|
||||||
dedges[i].v[1] = LittleShort (dedges[i].v[1]);
|
bsp->edges[i].v[1] = LittleShort (bsp->edges[i].v[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
bsp_t *
|
||||||
AddLump (int lumpnum, void *data, int len)
|
LoadBSPFile (QFile *file, int size)
|
||||||
{
|
{
|
||||||
lump_t *lump;
|
dheader_t *header;
|
||||||
|
bsp_t *bsp;
|
||||||
|
|
||||||
lump = &header->lumps[lumpnum];
|
header = malloc (size);
|
||||||
|
Qread (file, header, size);
|
||||||
|
|
||||||
lump->fileofs = LittleLong (Qtell (wadfile));
|
if (LittleLong (header->version) != BSPVERSION)
|
||||||
lump->filelen = LittleLong (len);
|
Sys_Error ("version %i, not %i", LittleLong (header->version),
|
||||||
Qwrite (wadfile, data, (len + 3) &~3);
|
BSPVERSION);
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
#undef SET_LUMP
|
||||||
CopyLump (int lump, void **dest, int size)
|
#define SET_LUMP(l,n) \
|
||||||
{
|
do { \
|
||||||
int length, ofs;
|
bsp->num##n = LittleLong (header->lumps[l].filelen); \
|
||||||
|
bsp->n = malloc (bsp->num##n); \
|
||||||
|
memcpy (bsp->n, (byte *) header + LittleLong (header->lumps[l].fileofs), \
|
||||||
|
bsp->num##n); \
|
||||||
|
bsp->num##n /= sizeof (bsp->n[0]); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
length = header->lumps[lump].filelen;
|
bsp = malloc (sizeof (bsp_t));
|
||||||
ofs = header->lumps[lump].fileofs;
|
SET_LUMP (LUMP_PLANES, planes);
|
||||||
|
SET_LUMP (LUMP_LEAFS, leafs);
|
||||||
|
SET_LUMP (LUMP_VERTEXES, vertexes);
|
||||||
|
SET_LUMP (LUMP_NODES, nodes);
|
||||||
|
SET_LUMP (LUMP_TEXINFO, texinfo);
|
||||||
|
SET_LUMP (LUMP_FACES, faces);
|
||||||
|
SET_LUMP (LUMP_CLIPNODES, clipnodes);
|
||||||
|
SET_LUMP (LUMP_MARKSURFACES, marksurfaces);
|
||||||
|
SET_LUMP (LUMP_SURFEDGES, surfedges);
|
||||||
|
SET_LUMP (LUMP_EDGES, edges);
|
||||||
|
SET_LUMP (LUMP_MODELS, models);
|
||||||
|
|
||||||
if (length % size)
|
#undef SET_LUMP
|
||||||
Sys_Error ("LoadBSPFile: odd lump size");
|
#define SET_LUMP(l,n) \
|
||||||
|
do { \
|
||||||
|
bsp->n##size = LittleLong (header->lumps[l].filelen); \
|
||||||
|
bsp->n = malloc (bsp->n##size); \
|
||||||
|
memcpy (bsp->n, (byte *) header + LittleLong (header->lumps[l].fileofs), \
|
||||||
|
bsp->n##size); \
|
||||||
|
bsp->n##size /= sizeof (bsp->n[0]); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
*dest = malloc (length);
|
SET_LUMP (LUMP_LIGHTING, lightdata);
|
||||||
if (!dest)
|
SET_LUMP (LUMP_VISIBILITY, visdata);
|
||||||
Sys_Error ("LoadBSPFile: out of memory");
|
SET_LUMP (LUMP_ENTITIES, entdata);
|
||||||
memcpy (*dest, (byte *) header + ofs, length);
|
SET_LUMP (LUMP_TEXTURES, texdata);
|
||||||
|
|
||||||
return length / size;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern int LoadFile (const char *filename, void **bufferptr);
|
|
||||||
|
|
||||||
void
|
|
||||||
LoadBSPFile (const char *filename)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// load the file header
|
|
||||||
LoadFile (filename, (void *) &header);
|
|
||||||
|
|
||||||
// swap the header
|
|
||||||
for (i = 0; i < sizeof (dheader_t) / 4; i++)
|
|
||||||
((int *) header)[i] = LittleLong (((int *) header)[i]);
|
|
||||||
|
|
||||||
if (header->version != BSPVERSION)
|
|
||||||
Sys_Error ("%s is version %i, not %i", filename, i, BSPVERSION);
|
|
||||||
//FIXME casting to (void**) isn't really portable :(
|
|
||||||
nummodels = CopyLump (LUMP_MODELS, (void **)&dmodels, sizeof (dmodel_t));
|
|
||||||
numvertexes = CopyLump (LUMP_VERTEXES, (void **)&dvertexes, sizeof (dvertex_t));
|
|
||||||
numplanes = CopyLump (LUMP_PLANES, (void **)&dplanes, sizeof (dplane_t));
|
|
||||||
numleafs = CopyLump (LUMP_LEAFS, (void **)&dleafs, sizeof (dleaf_t));
|
|
||||||
numnodes = CopyLump (LUMP_NODES, (void **)&dnodes, sizeof (dnode_t));
|
|
||||||
numtexinfo = CopyLump (LUMP_TEXINFO, (void **)&texinfo, sizeof (texinfo_t));
|
|
||||||
numclipnodes = CopyLump (LUMP_CLIPNODES, (void **)&dclipnodes, sizeof (dclipnode_t));
|
|
||||||
numfaces = CopyLump (LUMP_FACES, (void **)&dfaces, sizeof (dface_t));
|
|
||||||
nummarksurfaces = CopyLump (LUMP_MARKSURFACES, (void **)&dmarksurfaces,
|
|
||||||
sizeof (dmarksurfaces[0]));
|
|
||||||
numsurfedges = CopyLump (LUMP_SURFEDGES, (void **)&dsurfedges,
|
|
||||||
sizeof (dsurfedges[0]));
|
|
||||||
numedges = CopyLump (LUMP_EDGES, (void **)&dedges, sizeof (dedge_t));
|
|
||||||
|
|
||||||
texdatasize = CopyLump (LUMP_TEXTURES, (void **)&dtexdata, 1);
|
|
||||||
visdatasize = CopyLump (LUMP_VISIBILITY, (void **)&dvisdata, 1);
|
|
||||||
lightdatasize = CopyLump (LUMP_LIGHTING, (void **)&dlightdata, 1);
|
|
||||||
entdatasize = CopyLump (LUMP_ENTITIES, (void **)&dentdata, 1);
|
|
||||||
|
|
||||||
free (header);
|
free (header);
|
||||||
|
|
||||||
SwapBSPFile (false);
|
swap_bsp (bsp, 0);
|
||||||
|
return bsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -299,41 +229,74 @@ LoadBSPFile (const char *filename)
|
||||||
Swaps the bsp file in place, so it should not be referenced again
|
Swaps the bsp file in place, so it should not be referenced again
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
WriteBSPFile (const char *filename)
|
WriteBSPFile (bsp_t *bsp, QFile *file)
|
||||||
{
|
{
|
||||||
header = &outheader;
|
int size;
|
||||||
|
dheader_t *header;
|
||||||
|
byte *data;
|
||||||
|
|
||||||
|
size = sizeof (dheader_t);
|
||||||
|
size += bsp->nummodels * sizeof (dmodel_t);
|
||||||
|
size += bsp->visdatasize;
|
||||||
|
size += bsp->lightdatasize;
|
||||||
|
size += bsp->texdatasize;
|
||||||
|
size += bsp->entdatasize;
|
||||||
|
size += bsp->numleafs * sizeof (dleaf_t);
|
||||||
|
size += bsp->numplanes * sizeof (dplane_t);
|
||||||
|
size += bsp->numvertexes * sizeof (dvertex_t);
|
||||||
|
size += bsp->numnodes * sizeof (dnode_t);
|
||||||
|
size += bsp->numtexinfo * sizeof (texinfo_t);
|
||||||
|
size += bsp->numfaces * sizeof (dface_t);
|
||||||
|
size += bsp->numclipnodes * sizeof (dclipnode_t);
|
||||||
|
size += bsp->numedges * sizeof (dedge_t);
|
||||||
|
size += bsp->nummarksurfaces * sizeof (unsigned short);
|
||||||
|
size += bsp->numsurfedges * sizeof (int);
|
||||||
|
|
||||||
|
header = malloc (size);
|
||||||
memset (header, 0, sizeof (dheader_t));
|
memset (header, 0, sizeof (dheader_t));
|
||||||
|
|
||||||
SwapBSPFile (true);
|
swap_bsp (bsp, 1);
|
||||||
|
|
||||||
|
#undef SET_LUMP
|
||||||
|
#define SET_LUMP(l,n) \
|
||||||
|
do { \
|
||||||
|
bsp->num##n *= sizeof (bsp->n[0]); \
|
||||||
|
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
|
||||||
|
header->lumps[l].filelen = LittleLong (bsp->num##n); \
|
||||||
|
memcpy (data, bsp->n, bsp->num##n); \
|
||||||
|
data += bsp->num##n; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
header->version = LittleLong (BSPVERSION);
|
header->version = LittleLong (BSPVERSION);
|
||||||
|
|
||||||
wadfile = Qopen (filename, "wb");
|
data = (byte *) &header[1];
|
||||||
if (!wadfile)
|
SET_LUMP (LUMP_PLANES, planes);
|
||||||
Sys_Error ("Error opening %s", filename);
|
SET_LUMP (LUMP_LEAFS, leafs);
|
||||||
|
SET_LUMP (LUMP_VERTEXES, vertexes);
|
||||||
|
SET_LUMP (LUMP_NODES, nodes);
|
||||||
|
SET_LUMP (LUMP_TEXINFO, texinfo);
|
||||||
|
SET_LUMP (LUMP_FACES, faces);
|
||||||
|
SET_LUMP (LUMP_CLIPNODES, clipnodes);
|
||||||
|
SET_LUMP (LUMP_MARKSURFACES, marksurfaces);
|
||||||
|
SET_LUMP (LUMP_SURFEDGES, surfedges);
|
||||||
|
SET_LUMP (LUMP_EDGES, edges);
|
||||||
|
SET_LUMP (LUMP_MODELS, models);
|
||||||
|
|
||||||
Qwrite (wadfile, header, sizeof (dheader_t)); // overwritten later
|
#undef SET_LUMP
|
||||||
|
#define SET_LUMP(l,n) \
|
||||||
|
do { \
|
||||||
|
bsp->n##size *= sizeof (bsp->n[0]); \
|
||||||
|
header->lumps[l].fileofs = LittleLong (data - (byte *) header); \
|
||||||
|
header->lumps[l].filelen = LittleLong (bsp->n##size); \
|
||||||
|
memcpy (data, bsp->n, bsp->n##size); \
|
||||||
|
data += bsp->n##size; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
AddLump (LUMP_PLANES, dplanes, numplanes * sizeof (dplane_t));
|
SET_LUMP (LUMP_LIGHTING, lightdata);
|
||||||
AddLump (LUMP_LEAFS, dleafs, numleafs * sizeof (dleaf_t));
|
SET_LUMP (LUMP_VISIBILITY, visdata);
|
||||||
AddLump (LUMP_VERTEXES, dvertexes, numvertexes * sizeof (dvertex_t));
|
SET_LUMP (LUMP_ENTITIES, entdata);
|
||||||
AddLump (LUMP_NODES, dnodes, numnodes * sizeof (dnode_t));
|
SET_LUMP (LUMP_TEXTURES, texdata);
|
||||||
AddLump (LUMP_TEXINFO, texinfo, numtexinfo * sizeof (texinfo_t));
|
|
||||||
AddLump (LUMP_FACES, dfaces, numfaces * sizeof (dface_t));
|
|
||||||
AddLump (LUMP_CLIPNODES, dclipnodes, numclipnodes * sizeof (dclipnode_t));
|
|
||||||
AddLump (LUMP_MARKSURFACES, dmarksurfaces, nummarksurfaces
|
|
||||||
* sizeof (dmarksurfaces[0]));
|
|
||||||
AddLump (LUMP_SURFEDGES, dsurfedges, numsurfedges
|
|
||||||
* sizeof (dsurfedges[0]));
|
|
||||||
AddLump (LUMP_EDGES, dedges, numedges * sizeof (dedge_t));
|
|
||||||
AddLump (LUMP_MODELS, dmodels, nummodels * sizeof (dmodel_t));
|
|
||||||
|
|
||||||
AddLump (LUMP_LIGHTING, dlightdata, lightdatasize);
|
Qwrite (file, header, size);
|
||||||
AddLump (LUMP_VISIBILITY, dvisdata, visdatasize);
|
free (header);
|
||||||
AddLump (LUMP_ENTITIES, dentdata, entdatasize);
|
|
||||||
AddLump (LUMP_TEXTURES, dtexdata, texdatasize);
|
|
||||||
|
|
||||||
Qseek (wadfile, 0, SEEK_SET);
|
|
||||||
Qwrite (wadfile, header, sizeof (dheader_t));
|
|
||||||
Qclose (wadfile);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,6 @@ byte *GetFileSpace (int size);
|
||||||
void TransformSample (vec3_t in, vec3_t out);
|
void TransformSample (vec3_t in, vec3_t out);
|
||||||
void RotateSample (vec3_t in, vec3_t out);
|
void RotateSample (vec3_t in, vec3_t out);
|
||||||
|
|
||||||
|
extern struct bsp_s *bsp;
|
||||||
|
|
||||||
#endif// __light_h
|
#endif// __light_h
|
||||||
|
|
|
@ -130,7 +130,7 @@ LoadEntities (void)
|
||||||
epair_t *epair;
|
epair_t *epair;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
data = dentdata;
|
data = bsp->entdata;
|
||||||
|
|
||||||
// start parsing
|
// start parsing
|
||||||
num_entities = 0;
|
num_entities = 0;
|
||||||
|
@ -279,7 +279,7 @@ WriteEntitiesToString (void)
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf = dentdata;
|
buf = bsp->entdata;
|
||||||
end = buf;
|
end = buf;
|
||||||
*end = 0;
|
*end = 0;
|
||||||
|
|
||||||
|
@ -305,5 +305,5 @@ WriteEntitiesToString (void)
|
||||||
if (end > buf + MAX_MAP_ENTSTRING)
|
if (end > buf + MAX_MAP_ENTSTRING)
|
||||||
fprintf (stderr, "Entity text too long");
|
fprintf (stderr, "Entity text too long");
|
||||||
}
|
}
|
||||||
entdatasize = end - buf + 1;
|
bsp->entdatasize = end - buf + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ CalcFaceVectors (lightinfo_t *l)
|
||||||
float distscale;
|
float distscale;
|
||||||
vec_t dist, len;
|
vec_t dist, len;
|
||||||
|
|
||||||
tex = &texinfo[l->face->texinfo];
|
tex = &bsp->texinfo[l->face->texinfo];
|
||||||
|
|
||||||
// convert from float to vec_t
|
// convert from float to vec_t
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
|
@ -210,14 +210,14 @@ CalcFaceExtents (lightinfo_t *l)
|
||||||
mins[0] = mins[1] = 999999;
|
mins[0] = mins[1] = 999999;
|
||||||
maxs[0] = maxs[1] = -99999;
|
maxs[0] = maxs[1] = -99999;
|
||||||
|
|
||||||
tex = &texinfo[s->texinfo];
|
tex = &bsp->texinfo[s->texinfo];
|
||||||
|
|
||||||
for (i = 0; i < s->numedges; i++) {
|
for (i = 0; i < s->numedges; i++) {
|
||||||
e = dsurfedges[s->firstedge + i];
|
e = bsp->surfedges[s->firstedge + i];
|
||||||
if (e >= 0)
|
if (e >= 0)
|
||||||
v = dvertexes + dedges[e].v[0];
|
v = bsp->vertexes + bsp->edges[e].v[0];
|
||||||
else
|
else
|
||||||
v = dvertexes + dedges[-e].v[1];
|
v = bsp->vertexes + bsp->edges[-e].v[1];
|
||||||
|
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
val = v->point[0] * tex->vecs[j][0] +
|
val = v->point[0] * tex->vecs[j][0] +
|
||||||
|
@ -458,14 +458,14 @@ LightFace (int surfnum)
|
||||||
vec_t total;
|
vec_t total;
|
||||||
vec_t *light;
|
vec_t *light;
|
||||||
|
|
||||||
f = dfaces + surfnum;
|
f = bsp->faces + surfnum;
|
||||||
|
|
||||||
// some surfaces don't need lightmaps
|
// some surfaces don't need lightmaps
|
||||||
f->lightofs = -1;
|
f->lightofs = -1;
|
||||||
for (j = 0; j < MAXLIGHTMAPS; j++)
|
for (j = 0; j < MAXLIGHTMAPS; j++)
|
||||||
f->styles[j] = 255;
|
f->styles[j] = 255;
|
||||||
|
|
||||||
if (texinfo[f->texinfo].flags & TEX_SPECIAL)
|
if (bsp->texinfo[f->texinfo].flags & TEX_SPECIAL)
|
||||||
// non-lit texture
|
// non-lit texture
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -474,8 +474,8 @@ LightFace (int surfnum)
|
||||||
l.face = f;
|
l.face = f;
|
||||||
|
|
||||||
// rotate plane
|
// rotate plane
|
||||||
VectorCopy (dplanes[f->planenum].normal, l.facenormal);
|
VectorCopy (bsp->planes[f->planenum].normal, l.facenormal);
|
||||||
l.facedist = dplanes[f->planenum].dist;
|
l.facedist = bsp->planes[f->planenum].dist;
|
||||||
if (f->side) {
|
if (f->side) {
|
||||||
VectorSubtract (vec3_origin, l.facenormal, l.facenormal);
|
VectorSubtract (vec3_origin, l.facenormal, l.facenormal);
|
||||||
l.facedist = -l.facedist;
|
l.facedist = -l.facedist;
|
||||||
|
|
|
@ -59,6 +59,7 @@ static const char rcsid[] =
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
|
bsp_t *bsp;
|
||||||
|
|
||||||
char *bspfile;
|
char *bspfile;
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ LightThread (void *junk)
|
||||||
LOCK;
|
LOCK;
|
||||||
i = bspfileface++;
|
i = bspfileface++;
|
||||||
UNLOCK;
|
UNLOCK;
|
||||||
if (i >= numfaces)
|
if (i >= bsp->numfaces)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LightFace (i);
|
LightFace (i);
|
||||||
|
@ -110,21 +111,22 @@ LightThread (void *junk)
|
||||||
void
|
void
|
||||||
LightWorld (void)
|
LightWorld (void)
|
||||||
{
|
{
|
||||||
filebase = file_p = dlightdata;
|
filebase = file_p = bsp->lightdata;
|
||||||
file_end = filebase + MAX_MAP_LIGHTING;
|
file_end = filebase + MAX_MAP_LIGHTING;
|
||||||
|
|
||||||
RunThreadsOn (LightThread);
|
RunThreadsOn (LightThread);
|
||||||
|
|
||||||
lightdatasize = file_p - filebase;
|
bsp->lightdatasize = file_p - filebase;
|
||||||
|
|
||||||
if (options.verbosity >= 0)
|
if (options.verbosity >= 0)
|
||||||
printf ("lightdatasize: %i\n", lightdatasize);
|
printf ("lightdatasize: %i\n", bsp->lightdatasize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
double start, stop;
|
double start, stop;
|
||||||
|
QFile *f;
|
||||||
|
|
||||||
start = Sys_DoubleTime ();
|
start = Sys_DoubleTime ();
|
||||||
|
|
||||||
|
@ -142,15 +144,20 @@ main (int argc, char **argv)
|
||||||
COM_StripExtension (bspfile, bspfile);
|
COM_StripExtension (bspfile, bspfile);
|
||||||
COM_DefaultExtension (bspfile, ".bsp");
|
COM_DefaultExtension (bspfile, ".bsp");
|
||||||
|
|
||||||
LoadBSPFile (bspfile);
|
f = Qopen (bspfile, "rb");
|
||||||
|
bsp = LoadBSPFile (f, Qfilesize (f));
|
||||||
|
Qclose (f);
|
||||||
LoadEntities ();
|
LoadEntities ();
|
||||||
|
|
||||||
MakeTnodes (&dmodels[0]);
|
MakeTnodes (&bsp->models[0]);
|
||||||
|
|
||||||
LightWorld ();
|
LightWorld ();
|
||||||
|
|
||||||
WriteEntitiesToString ();
|
WriteEntitiesToString ();
|
||||||
WriteBSPFile (bspfile);
|
|
||||||
|
f = Qopen (bspfile, "wb");
|
||||||
|
WriteBSPFile (bsp, f);
|
||||||
|
Qclose (f);
|
||||||
|
|
||||||
stop = Sys_DoubleTime ();
|
stop = Sys_DoubleTime ();
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ MakeTnode (int nodenum)
|
||||||
|
|
||||||
t = tnode_p++;
|
t = tnode_p++;
|
||||||
|
|
||||||
node = dnodes + nodenum;
|
node = bsp->nodes + nodenum;
|
||||||
plane = dplanes + node->planenum;
|
plane = bsp->planes + node->planenum;
|
||||||
|
|
||||||
t->type = plane->type;
|
t->type = plane->type;
|
||||||
VectorCopy (plane->normal, t->normal);
|
VectorCopy (plane->normal, t->normal);
|
||||||
|
@ -100,7 +100,7 @@ MakeTnode (int nodenum)
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (node->children[i] < 0)
|
if (node->children[i] < 0)
|
||||||
t->children[i] = dleafs[-node->children[i] - 1].contents;
|
t->children[i] = bsp->leafs[-node->children[i] - 1].contents;
|
||||||
else {
|
else {
|
||||||
t->children[i] = tnode_p - tnodes;
|
t->children[i] = tnode_p - tnodes;
|
||||||
MakeTnode (node->children[i]);
|
MakeTnode (node->children[i]);
|
||||||
|
@ -116,7 +116,7 @@ MakeTnode (int nodenum)
|
||||||
void
|
void
|
||||||
MakeTnodes (dmodel_t *bm)
|
MakeTnodes (dmodel_t *bm)
|
||||||
{
|
{
|
||||||
tnode_p = tnodes = malloc (numnodes * sizeof (tnode_t));
|
tnode_p = tnodes = malloc (bsp->numnodes * sizeof (tnode_t));
|
||||||
|
|
||||||
MakeTnode (0);
|
MakeTnode (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,6 @@ void BasePortalVis (void);
|
||||||
void PortalFlow (portal_t *portal);
|
void PortalFlow (portal_t *portal);
|
||||||
void CalcAmbientSounds (void);
|
void CalcAmbientSounds (void);
|
||||||
|
|
||||||
|
extern struct bsp_s *bsp;
|
||||||
|
|
||||||
#endif// __vis_h
|
#endif// __vis_h
|
||||||
|
|
|
@ -66,6 +66,8 @@ static const char rcsid[] =
|
||||||
pthread_mutex_t *my_mutex;
|
pthread_mutex_t *my_mutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bsp_t *bsp;
|
||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
|
|
||||||
int numportals;
|
int numportals;
|
||||||
|
@ -451,19 +453,18 @@ LeafFlow (int leafnum)
|
||||||
vismap_p += i;
|
vismap_p += i;
|
||||||
|
|
||||||
if (vismap_p > vismap_end) {
|
if (vismap_p > vismap_end) {
|
||||||
int d = dest - dvisdata;
|
int d = dest - bsp->visdata;
|
||||||
int p = vismap_p - dvisdata;
|
int p = vismap_p - bsp->visdata;
|
||||||
int e = vismap_end - dvisdata;
|
int e = vismap_end - bsp->visdata;
|
||||||
|
bsp->visdatasize = p;
|
||||||
visdatasize = p;
|
vismap = bsp->visdata = realloc (bsp->visdata, bsp->visdatasize);
|
||||||
vismap = dvisdata = realloc (dvisdata, visdatasize);
|
dest = bsp->visdata + d;
|
||||||
dest = dvisdata + d;
|
vismap_p = bsp->visdata + p;
|
||||||
vismap_p = dvisdata + p;
|
vismap_end = bsp->visdata + e;
|
||||||
vismap_end = dvisdata + e;
|
|
||||||
fprintf (stderr, "Vismap grown\n");
|
fprintf (stderr, "Vismap grown\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
dleafs[leafnum + 1].visofs = dest - vismap; // leaf 0 is a common solid
|
bsp->leafs[leafnum + 1].visofs = dest - vismap; // leaf 0 is a common solid
|
||||||
|
|
||||||
memcpy (dest, compressed, i);
|
memcpy (dest, compressed, i);
|
||||||
}
|
}
|
||||||
|
@ -763,8 +764,8 @@ LoadPortals (char *name)
|
||||||
|
|
||||||
originalvismapsize = portalleafs * ((portalleafs + 7) / 8);
|
originalvismapsize = portalleafs * ((portalleafs + 7) / 8);
|
||||||
|
|
||||||
vismap = vismap_p = dvisdata;
|
vismap = vismap_p = bsp->visdata;
|
||||||
vismap_end = vismap + visdatasize;
|
vismap_end = vismap + bsp->visdatasize;
|
||||||
|
|
||||||
for (i = 0, portal = portals; i < numportals; i++) {
|
for (i = 0, portal = portals; i < numportals; i++) {
|
||||||
if (fscanf (f, "%i %i %i ", &numpoints, &leafnums[0],
|
if (fscanf (f, "%i %i %i ", &numpoints, &leafnums[0],
|
||||||
|
@ -831,6 +832,7 @@ main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
double start, stop;
|
double start, stop;
|
||||||
dstring_t *portalfile = dstring_new ();
|
dstring_t *portalfile = dstring_new ();
|
||||||
|
QFile *f;
|
||||||
|
|
||||||
start = Sys_DoubleTime ();
|
start = Sys_DoubleTime ();
|
||||||
|
|
||||||
|
@ -846,7 +848,9 @@ main (int argc, char **argv)
|
||||||
COM_StripExtension (options.bspfile, options.bspfile);
|
COM_StripExtension (options.bspfile, options.bspfile);
|
||||||
COM_DefaultExtension (options.bspfile, ".bsp");
|
COM_DefaultExtension (options.bspfile, ".bsp");
|
||||||
|
|
||||||
LoadBSPFile (options.bspfile);
|
f = Qopen (options.bspfile, "rb");
|
||||||
|
bsp = LoadBSPFile (f, Qfilesize (f));
|
||||||
|
Qclose (f);
|
||||||
|
|
||||||
portalfile->size = strlen (options.bspfile) + 1;
|
portalfile->size = strlen (options.bspfile) + 1;
|
||||||
dstring_adjust (portalfile);
|
dstring_adjust (portalfile);
|
||||||
|
@ -862,14 +866,16 @@ main (int argc, char **argv)
|
||||||
if (options.verbosity >= 0)
|
if (options.verbosity >= 0)
|
||||||
printf ("c_chains: %i\n", c_chains);
|
printf ("c_chains: %i\n", c_chains);
|
||||||
|
|
||||||
visdatasize = vismap_p - dvisdata;
|
bsp->visdatasize = vismap_p - bsp->visdata;
|
||||||
if (options.verbosity >= 0)
|
if (options.verbosity >= 0)
|
||||||
printf ("visdatasize:%i compressed from %i\n", visdatasize,
|
printf ("visdatasize:%i compressed from %i\n", bsp->visdatasize,
|
||||||
originalvismapsize);
|
originalvismapsize);
|
||||||
|
|
||||||
CalcAmbientSounds ();
|
CalcAmbientSounds ();
|
||||||
|
|
||||||
WriteBSPFile (options.bspfile);
|
f = Qopen (options.bspfile, "wb");
|
||||||
|
WriteBSPFile (bsp, f);
|
||||||
|
Qclose (f);
|
||||||
|
|
||||||
stop = Sys_DoubleTime ();
|
stop = Sys_DoubleTime ();
|
||||||
|
|
||||||
|
|
|
@ -75,12 +75,12 @@ SurfaceBBox (dface_t *s, vec3_t mins, vec3_t maxs)
|
||||||
maxs[0] = maxs[1] = -99999;
|
maxs[0] = maxs[1] = -99999;
|
||||||
|
|
||||||
for (i = 0; i < s->numedges; i++) {
|
for (i = 0; i < s->numedges; i++) {
|
||||||
e = dsurfedges[s->firstedge + i];
|
e = bsp->surfedges[s->firstedge + i];
|
||||||
if (e >= 0)
|
if (e >= 0)
|
||||||
vi = dedges[e].v[0];
|
vi = bsp->edges[e].v[0];
|
||||||
else
|
else
|
||||||
vi = dedges[-e].v[1];
|
vi = bsp->edges[-e].v[1];
|
||||||
v = dvertexes[vi].point;
|
v = bsp->vertexes[vi].point;
|
||||||
|
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
if (v[j] < mins[j])
|
if (v[j] < mins[j])
|
||||||
|
@ -105,7 +105,7 @@ CalcAmbientSounds (void)
|
||||||
miptex_t *miptex;
|
miptex_t *miptex;
|
||||||
|
|
||||||
for (i = 0; i < portalleafs; i++) {
|
for (i = 0; i < portalleafs; i++) {
|
||||||
leaf = &dleafs[i + 1];
|
leaf = &bsp->leafs[i + 1];
|
||||||
|
|
||||||
// clear ambients
|
// clear ambients
|
||||||
for (j = 0; j < NUM_AMBIENTS; j++)
|
for (j = 0; j < NUM_AMBIENTS; j++)
|
||||||
|
@ -118,13 +118,13 @@ CalcAmbientSounds (void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check this leaf for sound textures
|
// check this leaf for sound textures
|
||||||
hit = &dleafs[j + 1];
|
hit = &bsp->leafs[j + 1];
|
||||||
|
|
||||||
for (k = 0; k < hit->nummarksurfaces; k++) {
|
for (k = 0; k < hit->nummarksurfaces; k++) {
|
||||||
surf = &dfaces[dmarksurfaces[hit->firstmarksurface + k]];
|
surf = &bsp->faces[bsp->marksurfaces[hit->firstmarksurface + k]];
|
||||||
info = &texinfo[surf->texinfo];
|
info = &bsp->texinfo[surf->texinfo];
|
||||||
ofs = ((dmiptexlump_t *) dtexdata)->dataofs[info->miptex];
|
ofs = ((dmiptexlump_t *) bsp->texdata)->dataofs[info->miptex];
|
||||||
miptex = (miptex_t *) (&dtexdata[ofs]);
|
miptex = (miptex_t *) (&bsp->texdata[ofs]);
|
||||||
|
|
||||||
if (!strncasecmp (miptex->name, "*water", 6))
|
if (!strncasecmp (miptex->name, "*water", 6))
|
||||||
ambient_type = AMBIENT_WATER;
|
ambient_type = AMBIENT_WATER;
|
||||||
|
|
Loading…
Reference in a new issue