First step for BSP2 support. DOES NOT WORK!

All of the nastiness is hidden in bspfile.c (including the old bsp29
specific data types). However, the conversions between bsp29 and bsp2 are
implemented but not yet hooked up properly. This commit just gets the data
structures in place and the obvious changes necessary to the rest of the
engine to get it to compile, plus a few obvious "make it work" changes.
This commit is contained in:
Bill Currie 2012-09-07 16:09:24 +09:00
parent 69fb78278f
commit a37c5465e1
10 changed files with 485 additions and 58 deletions

View File

@ -45,6 +45,7 @@
//=============================================================================
#define BSPVERSION 29
#define BSP2VERSION "BSP2" // use memcmp with 4 bytes
#define Q2BSPVERSION 38
#define TOOLVERSION 2
@ -133,19 +134,20 @@ typedef struct dplane_s {
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dnode_s {
int32_t planenum;
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
int16_t mins[3]; // for sphere culling
int16_t maxs[3];
uint16_t firstface;
uint16_t numfaces; // counting both sides
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
float mins[3]; // for sphere culling
float maxs[3];
uint32_t firstface;
uint32_t numfaces; // counting both sides
} dnode_t;
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dclipnode_s {
int32_t planenum;
int16_t children[2]; // negative numbers are contents
int32_t children[2]; // negative numbers are contents
} dclipnode_t;
@ -159,18 +161,20 @@ typedef struct texinfo_s {
// note that edge 0 is never used, because negative edge nums are used for
// counterclockwise use of the edge in a face
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dedge_s {
uint16_t v[2]; // vertex numbers
uint32_t v[2]; // vertex numbers
} dedge_t;
#define MAXLIGHTMAPS 4
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dface_s {
int16_t planenum;
int16_t side;
int32_t planenum;
int32_t side;
int32_t firstedge; // we must support > 64k edges
int16_t numedges;
int16_t texinfo;
int32_t numedges;
int32_t texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
@ -187,15 +191,16 @@ typedef struct dface_s {
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
// all other leafs need visibility info
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dleaf_s {
int32_t contents;
int32_t visofs; // -1 = no visibility info
int16_t mins[3]; // for frustum culling
int16_t maxs[3];
float mins[3]; // for frustum culling
float maxs[3];
uint16_t firstmarksurface;
uint16_t nummarksurfaces;
uint32_t firstmarksurface;
uint32_t nummarksurfaces;
byte ambient_level[NUM_AMBIENTS];
} dleaf_t;
@ -260,7 +265,7 @@ typedef struct bsp_s {
int own_marksurfaces;
int nummarksurfaces;
uint16_t *marksurfaces;
uint32_t *marksurfaces;
int own_surfedges;
int numsurfedges;

View File

@ -121,7 +121,7 @@ typedef struct texture_s {
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct {
unsigned short v[2];
unsigned int v[2];
unsigned int cachededgeoffset;
} medge_t;
@ -192,8 +192,8 @@ typedef struct mnode_s {
plane_t *plane;
struct mnode_s *children[2];
unsigned short firstsurface;
unsigned short numsurfaces;
unsigned int firstsurface;
unsigned int numsurfaces;
} mnode_t;
typedef struct mleaf_s {

View File

@ -108,8 +108,8 @@
// medge_t structure
// !!! if this is changed, it must be changed in model.h too !!!
#define me_v 0
#define me_cachededgeoffset 4
#define me_size 8
#define me_cachededgeoffset 8
#define me_size 12
// mvertex_t structure
// !!! if this is changed, it must be changed in model.h too !!!

View File

@ -598,7 +598,8 @@ Mod_LoadNodes (bsp_t *bsp)
out->numsurfaces = in->numfaces;
for (j = 0; j < 2; j++) {
p = (uint16_t) in->children[j];
p = in->children[j];
// this check is for extended bsp 29 files
if (p < count) {
out->children[j] = loadmodel->nodes + p;
} else {
@ -725,8 +726,9 @@ Mod_LoadClipnodes (bsp_t *bsp)
out->planenum = in->planenum;
if (out->planenum < 0 || out->planenum >= loadmodel->numplanes)
Sys_Error ("Mod_LoadClipnodes: planenum out of bounds");
out->children[0] = (uint16_t) in->children[0];
out->children[1] = (uint16_t) in->children[1];
out->children[0] = in->children[0];
out->children[1] = in->children[1];
// these checks are for extended bsp 29 files
if (out->children[0] >= count)
out->children[0] -= 65536;
if (out->children[1] >= count)
@ -783,7 +785,7 @@ Mod_LoadMarksurfaces (bsp_t *bsp)
{
int count, i, j;
msurface_t **out;
uint16_t *in;
uint32_t *in;
in = bsp->marksurfaces;
count = bsp->nummarksurfaces;

View File

@ -43,6 +43,409 @@
#include "QF/quakefs.h"
#include "QF/sys.h"
typedef struct dnode29_s {
int32_t planenum;
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
int16_t mins[3]; // for sphere culling
int16_t maxs[3];
uint16_t firstface;
uint16_t numfaces; // counting both sides
} dnode29_t;
typedef struct dclipnode29_s {
int32_t planenum;
int16_t children[2]; // negative numbers are contents
} dclipnode29_t;
typedef struct dedge29_s {
uint16_t v[2]; // vertex numbers
} dedge29_t;
typedef struct dface29_s {
int16_t planenum;
int16_t side;
int32_t firstedge; // we must support > 64k edges
int16_t numedges;
int16_t texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
int32_t lightofs; // start of [numstyles*surfsize] samples
} dface29_t;
typedef struct dleaf29_s {
int32_t contents;
int32_t visofs; // -1 = no visibility info
int16_t mins[3]; // for frustum culling
int16_t maxs[3];
uint16_t firstmarksurface;
uint16_t nummarksurfaces;
byte ambient_level[NUM_AMBIENTS];
} dleaf29_t;
typedef struct bsp29_s {
int own_header;
dheader_t *header;
int own_models;
int nummodels;
dmodel_t *models;
int own_visdata;
size_t visdatasize;
byte *visdata;
int own_lightdata;
size_t lightdatasize;
byte *lightdata;
int own_texdata;
size_t texdatasize;
byte *texdata; // (dmiptexlump_t)
int own_entdata;
size_t entdatasize;
char *entdata;
int own_leafs;
int numleafs;
dleaf29_t *leafs;
int own_planes;
int numplanes;
dplane_t *planes;
int own_vertexes;
int numvertexes;
dvertex_t *vertexes;
int own_nodes;
int numnodes;
dnode29_t *nodes;
int own_texinfo;
int numtexinfo;
texinfo_t *texinfo;
int own_faces;
int numfaces;
dface29_t *faces;
int own_clipnodes;
int numclipnodes;
dclipnode29_t *clipnodes;
int own_edges;
int numedges;
dedge29_t *edges;
int own_marksurfaces;
int nummarksurfaces;
uint16_t *marksurfaces;
int own_surfedges;
int numsurfedges;
int32_t *surfedges;
} bsp29_t;
static void
swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
{
int c, i, j;
dmiptexlump_t *mtl;
dmodel_t *d;
if (bsp2->header && bsp29->header) {
bsp29->header->version = LittleLong (bsp2->header->version);
for (i = 0; i < HEADER_LUMPS; i++) {
bsp29->header->lumps[i].fileofs =
LittleLong (bsp2->header->lumps[i].fileofs);
bsp29->header->lumps[i].filelen =
LittleLong (bsp2->header->lumps[i].filelen);
}
}
// models
for (i=0 ; i<bsp29->nummodels ; i++) {
d = &bsp29->models[i];
for (j=0 ; j<MAX_MAP_HULLS ; j++)
d->headnode[j] = LittleLong (d->headnode[j]);
d->visleafs = LittleLong (d->visleafs);
d->firstface = LittleLong (d->firstface);
d->numfaces = LittleLong (d->numfaces);
for (j=0 ; j<3 ; j++) {
d->mins[j] = LittleFloat(d->mins[j]);
d->maxs[j] = LittleFloat(d->maxs[j]);
d->origin[j] = LittleFloat(d->origin[j]);
}
}
// vertexes
for (i=0 ; i<bsp29->numvertexes ; i++) {
dvertex_t *vertex = &bsp29->vertexes[i];
for (j=0 ; j<3 ; j++)
vertex->point[j] = LittleFloat (vertex->point[j]);
}
// planes
for (i=0 ; i<bsp29->numplanes ; i++) {
dplane_t *plane = &bsp29->planes[i];
for (j=0 ; j<3 ; j++)
plane->normal[j] = LittleFloat (plane->normal[j]);
plane->dist = LittleFloat (plane->dist);
plane->type = LittleLong (plane->type);
}
// texinfos
for (i=0 ; i<bsp29->numtexinfo ; i++) {
texinfo_t *texinfo = &bsp29->texinfo[i];
for (j=0 ; j<8 ; j++)
texinfo->vecs[0][j] = LittleFloat (texinfo->vecs[0][j]);
texinfo->miptex = LittleLong (texinfo->miptex);
texinfo->flags = LittleLong (texinfo->flags);
}
// faces
for (i=0 ; i<bsp29->numfaces ; i++) {
const dface_t *face2 = &bsp2->faces[i];
dface29_t *face29 = &bsp29->faces[i];
face29->planenum = LittleShort (face2->planenum);
face29->side = LittleShort (face2->side);
face29->firstedge = LittleLong (face2->firstedge);
face29->numedges = LittleShort (face2->numedges);
face29->texinfo = LittleShort (face2->texinfo);
memcpy (face29->styles, face2->styles, sizeof(face29->styles));
face29->lightofs = LittleLong (face2->lightofs);
}
// nodes
for (i=0 ; i<bsp29->numnodes ; i++) {
const dnode_t *node2 = &bsp2->nodes[i];
dnode29_t *node29 = &bsp29->nodes[i];
node29->planenum = LittleLong (node2->planenum);
for (j=0 ; j<3 ; j++) {
node29->mins[j] = LittleShort (node2->mins[j]);
node29->maxs[j] = LittleShort (node2->maxs[j]);
}
node29->children[0] = LittleShort (node2->children[0]);
node29->children[1] = LittleShort (node2->children[1]);
node29->firstface = LittleShort (node2->firstface);
node29->numfaces = LittleShort (node2->numfaces);
}
// leafs
for (i=0 ; i<bsp29->numleafs ; i++) {
const dleaf_t *leaf2 = &bsp2->leafs[i];
dleaf29_t *leaf29 = &bsp29->leafs[i];
leaf29->contents = LittleLong (leaf2->contents);
for (j=0 ; j<3 ; j++) {
leaf29->mins[j] = LittleShort (leaf2->mins[j]);
leaf29->maxs[j] = LittleShort (leaf2->maxs[j]);
}
leaf29->firstmarksurface = LittleShort (leaf2->firstmarksurface);
leaf29->nummarksurfaces = LittleShort (leaf2->nummarksurfaces);
leaf29->visofs = LittleLong (leaf2->visofs);
memcpy (leaf29->ambient_level, leaf2->ambient_level,
sizeof(leaf29->ambient_level));
}
// clipnodes
for (i=0 ; i<bsp29->numclipnodes ; i++) {
const dclipnode_t *clipnode2 = &bsp2->clipnodes[i];
dclipnode29_t *clipnode29 = (dclipnode29_t *) &bsp29->clipnodes[i];
clipnode29->planenum = LittleLong (clipnode2->planenum);
clipnode29->children[0] = LittleShort (clipnode2->children[0]);
clipnode29->children[1] = LittleShort (clipnode2->children[1]);
}
// miptex
if (bsp29->texdatasize) {
mtl = (dmiptexlump_t *)bsp29->texdata;
//miptexlumps have not yet been swapped
c = mtl->nummiptex;
mtl->nummiptex = LittleLong (mtl->nummiptex);
for (i=0 ; i<c ; i++)
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
}
// marksurfaces
for (i=0 ; i<bsp29->nummarksurfaces ; i++) {
const uint32_t *marksurface2 = &bsp2->marksurfaces[i];
uint16_t *marksurface29 = (uint16_t *) &bsp29->marksurfaces[i];
*marksurface29 = LittleShort (*marksurface2);
}
// surfedges
for (i=0 ; i<bsp29->numsurfedges ; i++) {
int32_t *surfedge = &bsp29->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
// edges
for (i=0 ; i<bsp29->numedges ; i++) {
const dedge_t *edge2 = &bsp2->edges[i];
dedge29_t *edge29 = (dedge29_t *) &bsp29->edges[i];
edge29->v[0] = LittleShort (edge2->v[0]);
edge29->v[1] = LittleShort (edge2->v[1]);
}
}
static void
swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
void (*cb) (const bsp_t *, void *), void *cbdata)
{
int c, i, j;
dmiptexlump_t *mtl;
dmodel_t *d;
if (bsp2->header) {
bsp2->header->version = LittleLong (bsp2->header->version);
for (i = 0; i < HEADER_LUMPS; i++) {
bsp2->header->lumps[i].fileofs =
LittleLong (bsp2->header->lumps[i].fileofs);
bsp2->header->lumps[i].filelen =
LittleLong (bsp2->header->lumps[i].filelen);
}
if (cb)
cb (bsp2, cbdata);
}
// models
for (i=0 ; i<bsp2->nummodels ; i++) {
d = &bsp2->models[i];
for (j=0 ; j<MAX_MAP_HULLS ; j++)
d->headnode[j] = LittleLong (d->headnode[j]);
d->visleafs = LittleLong (d->visleafs);
d->firstface = LittleLong (d->firstface);
d->numfaces = LittleLong (d->numfaces);
for (j=0 ; j<3 ; j++) {
d->mins[j] = LittleFloat(d->mins[j]);
d->maxs[j] = LittleFloat(d->maxs[j]);
d->origin[j] = LittleFloat(d->origin[j]);
}
}
// vertexes
for (i=0 ; i<bsp2->numvertexes ; i++) {
dvertex_t *vertex = &bsp2->vertexes[i];
for (j=0 ; j<3 ; j++)
vertex->point[j] = LittleFloat (vertex->point[j]);
}
// planes
for (i=0 ; i<bsp2->numplanes ; i++) {
dplane_t *plane = &bsp2->planes[i];
for (j=0 ; j<3 ; j++)
plane->normal[j] = LittleFloat (plane->normal[j]);
plane->dist = LittleFloat (plane->dist);
plane->type = LittleLong (plane->type);
}
// texinfos
for (i=0 ; i<bsp2->numtexinfo ; i++) {
texinfo_t *texinfo = &bsp2->texinfo[i];
for (j=0 ; j<8 ; j++)
texinfo->vecs[0][j] = LittleFloat (texinfo->vecs[0][j]);
texinfo->miptex = LittleLong (texinfo->miptex);
texinfo->flags = LittleLong (texinfo->flags);
}
// faces
for (i=0 ; i<bsp2->numfaces ; i++) {
dface_t *face2 = &bsp2->faces[i];
const dface29_t *face29 = &bsp29->faces[i];
face2->planenum = LittleShort (face29->planenum);
face2->side = LittleShort (face29->side);
face2->firstedge = LittleLong (face29->firstedge);
face2->numedges = LittleShort (face29->numedges);
face2->texinfo = LittleShort (face29->texinfo);
memcpy (face2->styles, face29->styles, sizeof(face2->styles));
face2->lightofs = LittleLong (face29->lightofs);
}
// nodes
for (i=0 ; i<bsp2->numnodes ; i++) {
dnode_t *node2 = &bsp2->nodes[i];
const dnode29_t *node29 = &bsp29->nodes[i];
node2->planenum = LittleLong (node29->planenum);
for (j=0 ; j<3 ; j++) {
node2->mins[j] = LittleShort (node29->mins[j]);
node2->maxs[j] = LittleShort (node29->maxs[j]);
}
node2->children[0] = LittleShort (node29->children[0]);
node2->children[1] = LittleShort (node29->children[1]);
node2->firstface = LittleShort (node29->firstface);
node2->numfaces = LittleShort (node29->numfaces);
}
// leafs
for (i=0 ; i<bsp2->numleafs ; i++) {
dleaf_t *leaf2 = &bsp2->leafs[i];
const dleaf29_t *leaf29 = &bsp29->leafs[i];
leaf2->contents = LittleLong (leaf29->contents);
for (j=0 ; j<3 ; j++) {
leaf2->mins[j] = LittleShort (leaf29->mins[j]);
leaf2->maxs[j] = LittleShort (leaf29->maxs[j]);
}
leaf2->firstmarksurface = LittleShort (leaf29->firstmarksurface);
leaf2->nummarksurfaces = LittleShort (leaf29->nummarksurfaces);
leaf2->visofs = LittleLong (leaf29->visofs);
memcpy (leaf2->ambient_level, leaf29->ambient_level,
sizeof(leaf2->ambient_level));
}
// clipnodes
for (i=0 ; i<bsp2->numclipnodes ; i++) {
dclipnode_t *clipnode2 = &bsp2->clipnodes[i];
const dclipnode29_t *clipnode29 = &bsp29->clipnodes[i];
clipnode2->planenum = LittleLong (clipnode29->planenum);
clipnode2->children[0] = LittleShort (clipnode29->children[0]);
clipnode2->children[1] = LittleShort (clipnode29->children[1]);
}
// miptex
if (bsp2->texdatasize) {
mtl = (dmiptexlump_t *)bsp2->texdata;
c = LittleLong(mtl->nummiptex);
mtl->nummiptex = LittleLong (mtl->nummiptex);
for (i=0 ; i<c ; i++)
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
}
// marksurfaces
for (i=0 ; i<bsp2->nummarksurfaces ; i++) {
uint32_t *marksurface2 = &bsp2->marksurfaces[i];
const uint16_t *marksurface29 = &bsp29->marksurfaces[i];
*marksurface2 = LittleShort (*marksurface29);
}
// surfedges
for (i=0 ; i<bsp2->numsurfedges ; i++) {
int32_t *surfedge = &bsp2->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
// edges
for (i=0 ; i<bsp2->numedges ; i++) {
dedge_t *edge2 = &bsp2->edges[i];
const dedge29_t *edge29 = &bsp29->edges[i];
edge2->v[0] = LittleShort (edge29->v[0]);
edge2->v[1] = LittleShort (edge29->v[1]);
}
}
static void
swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
void *cbdata)
@ -109,12 +512,12 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
// faces
for (i=0 ; i<bsp->numfaces ; i++) {
dface_t *face = &bsp->faces[i];
face->texinfo = LittleShort (face->texinfo);
face->planenum = LittleShort (face->planenum);
face->side = LittleShort (face->side);
face->texinfo = LittleLong (face->texinfo);
face->planenum = LittleLong (face->planenum);
face->side = LittleLong (face->side);
face->lightofs = LittleLong (face->lightofs);
face->firstedge = LittleLong (face->firstedge);
face->numedges = LittleShort (face->numedges);
face->numedges = LittleLong (face->numedges);
}
// nodes
@ -122,11 +525,11 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
dnode_t *node = &bsp->nodes[i];
node->planenum = LittleLong (node->planenum);
for (j=0 ; j<3 ; j++) {
node->mins[j] = LittleShort (node->mins[j]);
node->maxs[j] = LittleShort (node->maxs[j]);
node->mins[j] = LittleFloat (node->mins[j]);
node->maxs[j] = LittleFloat (node->maxs[j]);
}
node->children[0] = LittleShort (node->children[0]);
node->children[1] = LittleShort (node->children[1]);
node->children[0] = LittleLong (node->children[0]);
node->children[1] = LittleLong (node->children[1]);
node->firstface = LittleShort (node->firstface);
node->numfaces = LittleShort (node->numfaces);
}
@ -136,12 +539,12 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
dleaf_t *leaf = &bsp->leafs[i];
leaf->contents = LittleLong (leaf->contents);
for (j=0 ; j<3 ; j++) {
leaf->mins[j] = LittleShort (leaf->mins[j]);
leaf->maxs[j] = LittleShort (leaf->maxs[j]);
leaf->mins[j] = LittleFloat (leaf->mins[j]);
leaf->maxs[j] = LittleFloat (leaf->maxs[j]);
}
leaf->firstmarksurface = LittleShort (leaf->firstmarksurface);
leaf->nummarksurfaces = LittleShort (leaf->nummarksurfaces);
leaf->firstmarksurface = LittleLong (leaf->firstmarksurface);
leaf->nummarksurfaces = LittleLong (leaf->nummarksurfaces);
leaf->visofs = LittleLong (leaf->visofs);
}
@ -149,8 +552,8 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
for (i=0 ; i<bsp->numclipnodes ; i++) {
dclipnode_t *clipnode = &bsp->clipnodes[i];
clipnode->planenum = LittleLong (clipnode->planenum);
clipnode->children[0] = LittleShort (clipnode->children[0]);
clipnode->children[1] = LittleShort (clipnode->children[1]);
clipnode->children[0] = LittleLong (clipnode->children[0]);
clipnode->children[1] = LittleLong (clipnode->children[1]);
}
// miptex
@ -167,8 +570,8 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
// marksurfaces
for (i=0 ; i<bsp->nummarksurfaces ; i++) {
uint16_t *marksurface = &bsp->marksurfaces[i];
*marksurface = LittleShort (*marksurface);
uint32_t *marksurface = &bsp->marksurfaces[i];
*marksurface = LittleLong (*marksurface);
}
// surfedges
@ -180,8 +583,8 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
// edges
for (i=0 ; i<bsp->numedges ; i++) {
dedge_t *edge = &bsp->edges[i];
edge->v[0] = LittleShort (edge->v[0]);
edge->v[1] = LittleShort (edge->v[1]);
edge->v[0] = LittleLong (edge->v[0]);
edge->v[1] = LittleLong (edge->v[1]);
}
}
@ -191,14 +594,18 @@ LoadBSPMem (void *mem, size_t mem_size, void (*cb) (const bsp_t *, void *),
{
bsp_t *bsp;
int version;
qboolean bsp2 = false;
bsp = calloc (sizeof (bsp_t), 1);
bsp->header = mem;
version = LittleLong (bsp->header->version);
if (version != BSPVERSION)
Sys_Error ("version %i, not %i", version, BSPVERSION);
if (!memcmp (&bsp->header->version, BSP2VERSION, 4)) {
bsp2 = true;
} else if (version != BSPVERSION)
Sys_Error ("version %i, neither %i nor %s", version, BSPVERSION,
BSP2VERSION);
#undef SET_LUMP
#define SET_LUMP(l,n) \
@ -247,7 +654,10 @@ do { \
SET_LUMP (LUMP_ENTITIES, entdata);
SET_LUMP (LUMP_TEXTURES, texdata);
swap_bsp (bsp, 0, cb, cbdata);
if (bsp2)
swap_bsp (bsp, 0, cb, cbdata);
else
swap_from_bsp29 (bsp, 0, cb, cbdata);//FIXME
return bsp;
}
@ -273,6 +683,7 @@ WriteBSPFile (const bsp_t *bsp, QFile *file)
size_t size;
byte *data;
bsp_t tbsp;
qboolean bsp2 = false;
#define ROUND(x) (((x) + 3) & ~3)
@ -349,7 +760,10 @@ do { \
SET_LUMP (LUMP_ENTITIES, entdata);
SET_LUMP (LUMP_TEXTURES, texdata);
swap_bsp (&tbsp, 1, 0, 0);
if (bsp2)
swap_bsp (&tbsp, 1, 0, 0);
else
swap_to_bsp29 (0, &tbsp); //FIXME
Qwrite (file, tbsp.header, size);
free (tbsp.header);

View File

@ -204,7 +204,7 @@ void
R_RecursiveMarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
mnode_t *node)
{
int i;
unsigned i;
float ndist, maxdist;
plane_t *splitplane;
msurface_t *surf;
@ -400,7 +400,8 @@ calc_lighting_3 (msurface_t *surf, int ds, int dt)
static int
RecursiveLightPoint (mnode_t *node, const vec3_t start, const vec3_t end)
{
int i, r, s, t, ds, dt, side;
unsigned i;
int r, s, t, ds, dt, side;
float front, back, frac;
plane_t *plane;
msurface_t *surf;

View File

@ -66,7 +66,7 @@ texinfo_t *texinfo;
dvertex_t *vertices;
dedge_t *edges;
int *surfedges;
unsigned short *marksurfaces;
uint32_t *marksurfaces;
static brushset_t bs;
static void
@ -161,7 +161,8 @@ static void
load_leafs (void)
{
const dleaf_t *l;
int i, j;
int i;
unsigned j;
leafs = calloc (bsp->numleafs, sizeof (node_t));
for (i = 0; i < bsp->numleafs; i++) {
@ -184,7 +185,8 @@ load_nodes (void)
{
const dnode_t *n;
face_t *f;
int i, j;
int i;
unsigned j;
nodes = calloc (bsp->numnodes, sizeof (node_t));
for (i = 0; i < bsp->numnodes; i++) {

View File

@ -344,7 +344,8 @@ static int
GetEdge (const vec3_t p1, const vec3_t p2, face_t *f)
{
dedge_t edge;
int v1, v2, i;
unsigned v1, v2;
int i;
if (!f->contents[0])
Sys_Error ("GetEdge: 0 contents");

View File

@ -143,8 +143,9 @@ VisEntity (int ent_index)
entity_t *entity = entities + ent_index;
dleaf_t *leaf;
int ignorevis = false;
int i, j;
unsigned short *mark;
int i;
unsigned j;
uint32_t *mark;
byte *vis, *surfacehit;
int vis_size;
@ -202,7 +203,7 @@ VisEntity (int ent_index)
}
}
for (i = 1; i < bsp->nummodels; i++) {
for (j = 0; j < bsp->models[i].numfaces; j++) {
for (j = 0; (int) j < bsp->models[i].numfaces; j++) {
//FIXME vis
mark_face (bsp->models[i].firstface + j, surfacehit, entity);
}

View File

@ -94,7 +94,8 @@ void
CalcAmbientSounds (void)
{
byte *vis;
int ambient_type, ofs, i, j, k, l;
int ambient_type, ofs, i, j, l;
unsigned k;
float maxd, vol, d;
float dists[NUM_AMBIENTS];
dface_t *surf;