diff --git a/bsputil/bsputil.c b/bsputil/bsputil.c index daf156db..c8877329 100644 --- a/bsputil/bsputil.c +++ b/bsputil/bsputil.c @@ -27,14 +27,14 @@ /* FIXME - share header with qbsp, etc. */ typedef struct { char identification[4]; // should be WAD2 - int numlumps; - int infotableofs; + int32_t numlumps; + int32_t infotableofs; } wadinfo_t; typedef struct { - int filepos; - int disksize; - int size; // uncompressed + int32_t filepos; + int32_t disksize; + int32_t size; // uncompressed char type; char compression; char pad1, pad2; @@ -118,7 +118,7 @@ CheckBSPFacesPlanar(const bspdata_t *bsp) int i, j; for (i = 0; i < bsp->numfaces; i++) { - const dface_t *face = &bsp->dfaces[i]; + const bsp29_dface_t *face = &bsp->dfaces[i]; dplane_t plane = bsp->dplanes[face->planenum]; if (face->side) { @@ -146,7 +146,7 @@ CheckBSPFile(const bspdata_t *bsp) /* faces */ for (i = 0; i < bsp->numfaces; i++) { - const dface_t *face = &bsp->dfaces[i]; + const bsp29_dface_t *face = &bsp->dfaces[i]; /* texinfo bounds check */ if (face->texinfo < 0) @@ -184,7 +184,7 @@ CheckBSPFile(const bspdata_t *bsp) /* edges */ for (i = 0; i < bsp->numedges; i++) { - const dedge_t *edge = &bsp->dedges[i]; + const bsp29_dedge_t *edge = &bsp->dedges[i]; int j; for (j = 0; j < 2; j++) { @@ -218,7 +218,7 @@ CheckBSPFile(const bspdata_t *bsp) /* leafs */ for (i = 0; i < bsp->numleafs; i++) { - const dleaf_t *leaf = &bsp->dleafs[i]; + const bsp29_dleaf_t *leaf = &bsp->dleafs[i]; const uint16_t endmarksurface = leaf->firstmarksurface + leaf->nummarksurfaces; if (leaf->firstmarksurface < 0) @@ -238,7 +238,7 @@ CheckBSPFile(const bspdata_t *bsp) /* nodes */ for (i = 0; i < bsp->numnodes; i++) { - const dnode_t *node = &bsp->dnodes[i]; + const bsp29_dnode_t *node = &bsp->dnodes[i]; int j; for (j = 0; j < 2; j++) { diff --git a/common/bspfile.c b/common/bspfile.c index 9f3a4cbe..8c7d27d6 100644 --- a/common/bspfile.c +++ b/common/bspfile.c @@ -39,7 +39,7 @@ int entdatasize; char *dentdata; int numleafs; -dleaf_t *dleafs; +bsp29_dleaf_t *dleafs; int numplanes; dplane_t *dplanes; @@ -48,25 +48,25 @@ int numvertexes; dvertex_t *dvertexes; int numnodes; -dnode_t *dnodes; +bsp29_dnode_t *dnodes; int numtexinfo; texinfo_t *texinfo; int numfaces; -dface_t *dfaces; +bsp29_dface_t *dfaces; int numclipnodes; -dclipnode_t *dclipnodes; +bsp29_dclipnode_t *dclipnodes; int numedges; -dedge_t *dedges; +bsp29_dedge_t *dedges; int nummarksurfaces; -unsigned short *dmarksurfaces; +uint16_t *dmarksurfaces; int numsurfedges; -int *dsurfedges; +int32_t *dsurfedges; /* Transitional helper functions */ void @@ -211,7 +211,7 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) /* faces */ for (i = 0; i < bspdata->numfaces; i++) { - dface_t *face = &bspdata->dfaces[i]; + bsp29_dface_t *face = &bspdata->dfaces[i]; face->texinfo = LittleShort(face->texinfo); face->planenum = LittleShort(face->planenum); face->side = LittleShort(face->side); @@ -222,7 +222,7 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) /* nodes */ for (i = 0; i < bspdata->numnodes; i++) { - dnode_t *node = &bspdata->dnodes[i]; + bsp29_dnode_t *node = &bspdata->dnodes[i]; node->planenum = LittleLong(node->planenum); for (j = 0; j < 3; j++) { node->mins[j] = LittleShort(node->mins[j]); @@ -236,7 +236,7 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) /* leafs */ for (i = 0; i < bspdata->numleafs; i++) { - dleaf_t *leaf = &bspdata->dleafs[i]; + bsp29_dleaf_t *leaf = &bspdata->dleafs[i]; leaf->contents = LittleLong(leaf->contents); for (j = 0; j < 3; j++) { leaf->mins[j] = LittleShort(leaf->mins[j]); @@ -249,7 +249,7 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) /* clipnodes */ for (i = 0; i < bspdata->numclipnodes; i++) { - dclipnode_t *clipnode = &bspdata->dclipnodes[i]; + bsp29_dclipnode_t *clipnode = &bspdata->dclipnodes[i]; clipnode->planenum = LittleLong(clipnode->planenum); clipnode->children[0] = LittleShort(clipnode->children[0]); clipnode->children[1] = LittleShort(clipnode->children[1]); @@ -269,19 +269,19 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) /* marksurfaces */ for (i = 0; i < bspdata->nummarksurfaces; i++) { - unsigned short *marksurface = &bspdata->dmarksurfaces[i]; + uint16_t *marksurface = &bspdata->dmarksurfaces[i]; *marksurface = LittleShort(*marksurface); } /* surfedges */ for (i = 0; i < bspdata->numsurfedges; i++) { - int *surfedge = &bspdata->dsurfedges[i]; + int32_t *surfedge = &bspdata->dsurfedges[i]; *surfedge = LittleLong(*surfedge); } /* edges */ for (i = 0; i < bspdata->numedges; i++) { - dedge_t *edge = &bspdata->dedges[i]; + bsp29_dedge_t *edge = &bspdata->dedges[i]; edge->v[0] = LittleShort(edge->v[0]); edge->v[1] = LittleShort(edge->v[1]); } @@ -303,21 +303,21 @@ SwapBSPFile(bspdata_t *bspdata, swaptype_t swap) } const lumpspec_t lumpspec[] = { - { "entities", sizeof(char) }, - { "planes", sizeof(dplane_t) }, - { "texture", sizeof(byte) }, - { "vertexes", sizeof(dvertex_t) }, - { "visibility", sizeof(byte) }, - { "nodes", sizeof(dnode_t) }, - { "texinfos", sizeof(texinfo_t) }, - { "faces", sizeof(dface_t) }, - { "lighting", sizeof(byte) }, - { "clipnodes", sizeof(dclipnode_t) }, - { "leafs", sizeof(dleaf_t) }, - { "marksurfaces", sizeof(unsigned short) }, - { "edges", sizeof(dedge_t) }, - { "surfedges", sizeof(int) }, - { "models", sizeof(dmodel_t) }, + { "entities", sizeof(char) }, + { "planes", sizeof(dplane_t) }, + { "texture", sizeof(byte) }, + { "vertexes", sizeof(dvertex_t) }, + { "visibility", sizeof(byte) }, + { "nodes", sizeof(bsp29_dnode_t) }, + { "texinfos", sizeof(texinfo_t) }, + { "faces", sizeof(bsp29_dface_t) }, + { "lighting", sizeof(byte) }, + { "clipnodes", sizeof(bsp29_dclipnode_t) }, + { "leafs", sizeof(bsp29_dleaf_t) }, + { "marksurfaces", sizeof(uint16_t) }, + { "edges", sizeof(bsp29_dedge_t) }, + { "surfedges", sizeof(int32_t) }, + { "models", sizeof(dmodel_t) }, }; static int diff --git a/include/common/bspfile.h b/include/common/bspfile.h index 729be04c..cbeb66e2 100644 --- a/include/common/bspfile.h +++ b/include/common/bspfile.h @@ -136,7 +136,6 @@ typedef struct { #define CONTENTS_LAVA -5 #define CONTENTS_SKY -6 -/* !!! if this is changed, it must be changed in asm_i386.h too !!! */ typedef struct { int32_t planenum; int16_t children[2]; /* negative numbers are -(leafs+1), not nodes */ @@ -144,12 +143,32 @@ typedef struct { int16_t maxs[3]; uint16_t firstface; uint16_t numfaces; /* counting both sides */ -} dnode_t; +} bsp29_dnode_t; typedef struct { int32_t planenum; - int16_t children[2]; /* negative numbers are contents */ -} dclipnode_t; + int32_t children[2]; /* negative numbers are -(leafs+1), not nodes */ + int16_t mins[3]; /* for sphere culling */ + int16_t maxs[3]; + uint32_t firstface; + uint32_t numfaces; /* counting both sides */ +} bsp2_dnode_t; + +/* + * Note that children are interpreted as unsigned values now, so that we can + * handle > 32k clipnodes. Values > 0xFFF0 can be assumed to be CONTENTS + * values and can be read as the signed value to be compatible with the above + * (i.e. simply subtract 65536). + */ +typedef struct { + int32_t planenum; + int16_t children[2]; /* negative numbers are contents */ +} bsp29_dclipnode_t; + +typedef struct { + int32_t planenum; + int32_t children[2]; /* negative numbers are contents */ +} bsp2_dclipnode_t; typedef struct texinfo_s { float vecs[2][4]; /* [s/t][xyz offset] */ @@ -159,12 +178,17 @@ typedef struct texinfo_s { #define TEX_SPECIAL 1 /* sky or slime, no lightmap or 256 subdivision */ -/* note that edge 0 is never used, because negative edge nums are used for +/* + * Note that edge 0 is never used, because negative edge nums are used for * counterclockwise use of the edge in a face */ typedef struct { uint16_t v[2]; /* vertex numbers */ -} dedge_t; +} bsp29_dedge_t; + +typedef struct { + uint32_t v[2]; /* vertex numbers */ +} bsp2_dedge_t; #define MAXLIGHTMAPS 4 typedef struct { @@ -177,7 +201,19 @@ typedef struct { /* lighting info */ uint8_t styles[MAXLIGHTMAPS]; int32_t lightofs; /* start of [numstyles*surfsize] samples */ -} dface_t; +} bsp29_dface_t; + +typedef struct { + int32_t planenum; + int32_t side; + int32_t firstedge; /* we must support > 64k edges */ + int32_t numedges; + int32_t texinfo; + + /* lighting info */ + uint8_t styles[MAXLIGHTMAPS]; + int32_t lightofs; /* start of [numstyles*surfsize] samples */ +} bsp2_dface_t; /* Ambient Sounds */ #define AMBIENT_WATER 0 @@ -195,12 +231,20 @@ typedef struct { int32_t visofs; /* -1 = no visibility info */ int16_t mins[3]; /* for frustum culling */ int16_t maxs[3]; - uint16_t firstmarksurface; uint16_t nummarksurfaces; - uint8_t ambient_level[NUM_AMBIENTS]; -} dleaf_t; +} bsp29_dleaf_t; + +typedef struct { + int32_t contents; + int32_t visofs; /* -1 = no visibility info */ + int16_t mins[3]; /* for frustum culling */ + int16_t maxs[3]; + uint32_t firstmarksurface; + uint32_t nummarksurfaces; + uint8_t ambient_level[NUM_AMBIENTS]; +} bsp2_dleaf_t; /* ========================================================================= */ @@ -225,7 +269,7 @@ extern int entdatasize; extern char *dentdata; extern int numleafs; -extern dleaf_t *dleafs; +extern bsp29_dleaf_t *dleafs; extern int numplanes; extern dplane_t *dplanes; @@ -234,19 +278,19 @@ extern int numvertexes; extern dvertex_t *dvertexes; extern int numnodes; -extern dnode_t *dnodes; +extern bsp29_dnode_t *dnodes; extern int numtexinfo; extern texinfo_t *texinfo; extern int numfaces; -extern dface_t *dfaces; +extern bsp29_dface_t *dfaces; extern int numclipnodes; -extern dclipnode_t *dclipnodes; +extern bsp29_dclipnode_t *dclipnodes; extern int numedges; -extern dedge_t *dedges; +extern bsp29_dedge_t *dedges; extern int nummarksurfaces; extern unsigned short *dmarksurfaces; @@ -272,7 +316,7 @@ typedef struct { char *dentdata; int numleafs; - dleaf_t *dleafs; + bsp29_dleaf_t *dleafs; int numplanes; dplane_t *dplanes; @@ -281,19 +325,19 @@ typedef struct { dvertex_t *dvertexes; int numnodes; - dnode_t *dnodes; + bsp29_dnode_t *dnodes; int numtexinfo; texinfo_t *texinfo; int numfaces; - dface_t *dfaces; + bsp29_dface_t *dfaces; int numclipnodes; - dclipnode_t *dclipnodes; + bsp29_dclipnode_t *dclipnodes; int numedges; - dedge_t *dedges; + bsp29_dedge_t *dedges; int nummarksurfaces; uint16_t *dmarksurfaces; diff --git a/include/light/light.h b/include/light/light.h index 62060513..d1a2270b 100644 --- a/include/light/light.h +++ b/include/light/light.h @@ -87,7 +87,7 @@ typedef struct { /* tracelist is a null terminated array of BSP models to use for LOS tests */ extern const dmodel_t *const *tracelist; -void LightFace(dface_t *face, const modelinfo_t *modelinfo); +void LightFace(bsp29_dface_t *face, const modelinfo_t *modelinfo); void MakeTnodes(void); extern float scaledist; diff --git a/light/ltface.c b/light/ltface.c index e172633d..fb1c6aba 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -118,7 +118,7 @@ Solve3(const pmatrix3_t *matrix, const vec3_t rhs, vec3_t out) /* * ============================================================================ * SAMPLE POINT DETERMINATION - * void SetupBlock (dface_t *f) Returns with surfpt[] set + * void SetupBlock (bsp29_dface_t *f) Returns with surfpt[] set * * This is a little tricky because the lightmap covers more area than the face. * If done in the straightforward fashion, some of the sample points will be @@ -194,7 +194,7 @@ TriArea(const dvertex_t *v0, const dvertex_t *v1, const dvertex_t *v2) } static vec_t -FaceArea(const dface_t *f) +FaceArea(const bsp29_dface_t *f) { int i, e; dvertex_t *v0, *v1, *v2; @@ -222,7 +222,7 @@ FaceArea(const dface_t *f) } static void -FaceCentroid(const dface_t *f, vec3_t out) +FaceCentroid(const bsp29_dface_t *f, vec3_t out) { int i, e; dvertex_t *v0, *v1, *v2; @@ -265,7 +265,7 @@ FaceCentroid(const dface_t *f, vec3_t out) * ================ */ static void -CreateFaceTransform(const dface_t *face, pmatrix3_t *transform) +CreateFaceTransform(const bsp29_dface_t *face, pmatrix3_t *transform) { const dplane_t *plane; const texinfo_t *tex; @@ -319,7 +319,7 @@ WorldToTexCoord(const vec3_t world, const texinfo_t *tex, vec_t coord[2]) #if 0 /* Debug helper - move elsewhere? */ static void -PrintFaceInfo(const dface_t *face) +PrintFaceInfo(const bsp29_dface_t *face) { const texinfo_t *tex = &texinfo[face->texinfo]; const int offset = dtexdata.header->dataofs[tex->miptex]; @@ -353,7 +353,7 @@ PrintFaceInfo(const dface_t *face) */ __attribute__((noinline)) static void -CalcFaceExtents(const dface_t *face, const vec3_t offset, lightsurf_t *surf) +CalcFaceExtents(const bsp29_dface_t *face, const vec3_t offset, lightsurf_t *surf) { vec_t mins[2], maxs[2], texcoord[2]; vec3_t worldpoint; @@ -490,7 +490,7 @@ CalcPoints(const dmodel_t *model, const texorg_t *texorg, lightsurf_t *surf) __attribute__((noinline)) static void -Lightsurf_Init(const modelinfo_t *modelinfo, const dface_t *face, +Lightsurf_Init(const modelinfo_t *modelinfo, const bsp29_dface_t *face, lightsurf_t *lightsurf) { plane_t *plane; @@ -875,7 +875,7 @@ LightFace_Min(const lightsample_t *light, } static void -WriteLightmaps(dface_t *face, const lightsurf_t *lightsurf, +WriteLightmaps(bsp29_dface_t *face, const lightsurf_t *lightsurf, const lightmap_t *lightmaps) { int numstyles, size, mapnum, width, s, t, i, j; @@ -953,7 +953,7 @@ WriteLightmaps(dface_t *face, const lightsurf_t *lightsurf, * ============ */ void -LightFace(dface_t *face, const modelinfo_t *modelinfo) +LightFace(bsp29_dface_t *face, const modelinfo_t *modelinfo) { int i, j, k; const entity_t *entity; diff --git a/light/trace.c b/light/trace.c index 40b783c9..367664c6 100644 --- a/light/trace.c +++ b/light/trace.c @@ -42,7 +42,7 @@ MakeTnodes_r(int nodenum) tnode_t *t; dplane_t *plane; int i; - dnode_t *node; + bsp29_dnode_t *node; t = tnode_p++; diff --git a/qbsp/bspfile.h b/qbsp/bspfile.h index 10b80560..ae4cee5d 100644 --- a/qbsp/bspfile.h +++ b/qbsp/bspfile.h @@ -175,26 +175,20 @@ typedef struct { typedef struct { 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; - uint8_t ambient_level[NUM_AMBIENTS]; } bsp29_dleaf_t; typedef struct { int32_t contents; int32_t visofs; /* -1 = no visibility info */ - int16_t mins[3]; /* for frustum culling */ int16_t maxs[3]; - uint32_t firstmarksurface; uint32_t nummarksurfaces; - uint8_t ambient_level[NUM_AMBIENTS]; } bsp2_dleaf_t; diff --git a/vis/soundpvs.c b/vis/soundpvs.c index 2a6b419a..f1d1b215 100644 --- a/vis/soundpvs.c +++ b/vis/soundpvs.c @@ -34,7 +34,7 @@ Find an aproximate distance to the nearest emiter of each class for each leaf. ==================== */ static void -SurfaceBBox(const dface_t *s, vec3_t mins, vec3_t maxs) +SurfaceBBox(const bsp29_dface_t *s, vec3_t mins, vec3_t maxs) { int i, j; int e; @@ -70,11 +70,11 @@ SurfaceBBox(const dface_t *s, vec3_t mins, vec3_t maxs) void CalcAmbientSounds(void) { - const dface_t *surf; + const bsp29_dface_t *surf; const texinfo_t *info; const miptex_t *miptex; int i, j, k, l; - dleaf_t *leaf, *hit; + bsp29_dleaf_t *leaf, *hit; byte *vis; vec3_t mins, maxs; float d, maxd;