[util] Make bsp_t counts size_t

and other bsp data counts unsigned, and clean up the resulting mess.
This commit is contained in:
Bill Currie 2021-08-01 21:54:05 +09:00
parent 40367e5bca
commit 674ffa0941
26 changed files with 288 additions and 323 deletions

View file

@ -52,8 +52,8 @@
#define TOOLVERSION 2
typedef struct lump_s {
int32_t fileofs;
int32_t filelen;
uint32_t fileofs;
uint32_t filelen;
} lump_t;
#define LUMP_ENTITIES 0
@ -76,19 +76,19 @@ typedef struct lump_s {
typedef struct dmodel_s {
float mins[3], maxs[3];
float origin[3];
int32_t headnode[MAX_MAP_HULLS];
int32_t visleafs; // not including the solid leaf 0
int32_t firstface, numfaces;
uint32_t headnode[MAX_MAP_HULLS];
uint32_t visleafs; // not including the solid leaf 0
uint32_t firstface, numfaces;
} dmodel_t;
typedef struct dheader_s {
int32_t version;
uint32_t version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct dmiptexlump_s {
int32_t nummiptex;
int32_t dataofs[4]; // [nummiptex]
uint32_t nummiptex;
uint32_t dataofs[4]; // [nummiptex]
} dmiptexlump_t;
#define MIPTEXNAME 16
@ -138,7 +138,7 @@ typedef struct dplane_s {
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dnode_s {
int32_t planenum;
uint32_t planenum;
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
float mins[3]; // for sphere culling
float maxs[3];
@ -148,15 +148,15 @@ typedef struct dnode_s {
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dclipnode_s {
int32_t planenum;
uint32_t planenum;
int32_t children[2]; // negative numbers are contents
} dclipnode_t;
typedef struct texinfo_s {
float vecs[2][4]; // [s/t][xyz offset]
int32_t miptex;
int32_t flags;
uint32_t miptex;
uint32_t flags;
} texinfo_t;
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
#define TEX_MISSING 2 // this texinfo does not have a texture
@ -171,16 +171,16 @@ typedef struct dedge_s {
#define MAXLIGHTMAPS 4
//BSP2 version (bsp 29 version is in bspfile.c)
typedef struct dface_s {
int32_t planenum;
uint32_t planenum;
int32_t side;
int32_t firstedge; // we must support > 64k edges
int32_t numedges;
int32_t texinfo;
uint32_t firstedge; // we must support > 64k edges
uint32_t numedges;
uint32_t texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
int32_t lightofs; // start of [numstyles*surfsize] samples
uint32_t lightofs; // start of [numstyles*surfsize] samples
} dface_t;
@ -214,7 +214,7 @@ typedef struct bsp_s {
dheader_t *header;
int own_models;
int nummodels;
size_t nummodels;
dmodel_t *models;
int own_visdata;
@ -234,43 +234,43 @@ typedef struct bsp_s {
char *entdata;
int own_leafs;
int numleafs;
size_t numleafs;
dleaf_t *leafs;
int own_planes;
int numplanes;
size_t numplanes;
dplane_t *planes;
int own_vertexes;
int numvertexes;
size_t numvertexes;
dvertex_t *vertexes;
int own_nodes;
int numnodes;
size_t numnodes;
dnode_t *nodes;
int own_texinfo;
int numtexinfo;
size_t numtexinfo;
texinfo_t *texinfo;
int own_faces;
int numfaces;
size_t numfaces;
dface_t *faces;
int own_clipnodes;
int numclipnodes;
size_t numclipnodes;
dclipnode_t *clipnodes;
int own_edges;
int numedges;
size_t numedges;
dedge_t *edges;
int own_marksurfaces;
int nummarksurfaces;
size_t nummarksurfaces;
uint32_t *marksurfaces;
int own_surfedges;
int numsurfedges;
size_t numsurfedges;
int32_t *surfedges;
} bsp_t;

View file

@ -206,7 +206,7 @@ typedef struct mleaf_s {
} mleaf_t;
typedef struct mclipnode_s {
int planenum;
unsigned planenum;
int children[2];
} mclipnode_t;
@ -222,57 +222,57 @@ typedef struct hull_s {
} hull_t;
typedef struct mod_brush_s {
int firstmodelsurface, nummodelsurfaces;
unsigned firstmodelsurface, nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
unsigned numsubmodels;
dmodel_t *submodels;
int numplanes;
plane_t *planes;
unsigned numplanes;
plane_t *planes;
unsigned modleafs; ///< number of leafs in model, including 0
unsigned visleafs; ///< number of visible leafs, not counting 0
mleaf_t *leafs;
mleaf_t *leafs;
int numvertexes;
mvertex_t *vertexes;
unsigned numvertexes;
mvertex_t *vertexes;
int numedges;
medge_t *edges;
unsigned numedges;
medge_t *edges;
int numnodes;
mnode_t *nodes;
int depth; ///< maximum depth of the tree
unsigned numnodes;
mnode_t *nodes;
int depth; ///< maximum depth of the tree
int numtexinfo;
mtexinfo_t *texinfo;
unsigned numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
unsigned numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
unsigned numsurfedges;
int *surfedges;
int numclipnodes;
mclipnode_t *clipnodes;
unsigned numclipnodes;
mclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
unsigned nummarksurfaces;
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
hull_t *hull_list[MAX_MAP_HULLS];
hull_t hulls[MAX_MAP_HULLS];
hull_t *hull_list[MAX_MAP_HULLS];
int numtextures;
texture_t **textures;
texture_t *skytexture;
unsigned numtextures;
texture_t **textures;
texture_t *skytexture;
byte *visdata;
byte *lightdata;
char *entities; //FIXME should not be here
byte *visdata;
byte *lightdata;
char *entities; //FIXME should not be here
mnode_t **node_parents;
mnode_t **leaf_parents;
int *leaf_flags; // union of surf flags for surfs in leaf
mnode_t **node_parents;
mnode_t **leaf_parents;
int *leaf_flags; // union of surf flags for surfs in leaf
unsigned int checksum;
unsigned int checksum2;

View file

@ -65,11 +65,10 @@ static glsltex_t glsl_notexture = { };
static void
glsl_brush_clear (model_t *m, void *data)
{
int i;
mod_brush_t *brush = &m->brush;
m->needload = true;
for (i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
// NOTE: some maps (eg e1m2) have empty texture slots
glsltex_t *tex = 0;
if (brush->textures[i]) {
@ -82,7 +81,7 @@ glsl_brush_clear (model_t *m, void *data)
tex->gl_texturenum = 0;
}
}
for (i = 0; i < brush->numsurfaces; i++) {
for (unsigned i = 0; i < brush->numsurfaces; i++) {
if (brush->surfaces[i].polys) {
free (brush->surfaces[i].polys);
brush->surfaces[i].polys = 0;

View file

@ -247,7 +247,7 @@ static void
Mod_LoadTextures (model_t *mod, bsp_t *bsp)
{
dmiptexlump_t *m;
int i, j, pixels, num, max, altmax;
int pixels, num, max, altmax;
miptex_t *mt;
texture_t *tx, *tx2;
texture_t *anims[10], *altanims[10];
@ -264,13 +264,13 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
m->nummiptex * sizeof (*brush->textures),
mod->name);
for (i = 0; i < m->nummiptex; i++) {
if (m->dataofs[i] == -1)
for (uint32_t i = 0; i < m->nummiptex; i++) {
if (m->dataofs[i] == ~0u)
continue;
mt = (miptex_t *) ((byte *) m + m->dataofs[i]);
mt->width = LittleLong (mt->width);
mt->height = LittleLong (mt->height);
for (j = 0; j < MIPLEVELS; j++)
for (int j = 0; j < MIPLEVELS; j++)
mt->offsets[j] = LittleLong (mt->offsets[j]);
if ((mt->width & 15) || (mt->height & 15))
@ -284,7 +284,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
mod_unique_miptex_name (brush->textures, tx, i);
tx->width = mt->width;
tx->height = mt->height;
for (j = 0; j < MIPLEVELS; j++)
for (int j = 0; j < MIPLEVELS; j++)
tx->offsets[j] =
mt->offsets[j] + sizeof (texture_t) - sizeof (miptex_t);
// the pixels immediately follow the structures
@ -300,7 +300,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
render_data = Hunk_AllocName (0, m->nummiptex * render_size,
mod->name);
}
for (i = 0; i < m->nummiptex; i++) {
for (uint32_t i = 0; i < m->nummiptex; i++) {
if (!(tx = brush->textures[i])) {
continue;
}
@ -313,7 +313,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
}
// sequence the animations
for (i = 0; i < m->nummiptex; i++) {
for (uint32_t i = 0; i < m->nummiptex; i++) {
tx = brush->textures[i];
if (!tx || tx->name[0] != '+')
continue;
@ -340,7 +340,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
} else
Sys_Error ("Bad animating texture %s", tx->name);
for (j = i + 1; j < m->nummiptex; j++) {
for (uint32_t j = i + 1; j < m->nummiptex; j++) {
tx2 = brush->textures[j];
if (!tx2 || tx2->name[0] != '+')
continue;
@ -366,7 +366,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
#define ANIM_CYCLE 2
// link them all together
for (j = 0; j < max; j++) {
for (int j = 0; j < max; j++) {
tx2 = anims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s", j, tx->name);
@ -377,7 +377,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
if (altmax)
tx2->alternate_anims = altanims[0];
}
for (j = 0; j < altmax; j++) {
for (int j = 0; j < altmax; j++) {
tx2 = altanims[j];
if (!tx2)
Sys_Error ("Missing frame %i of %s", j, tx->name);
@ -490,7 +490,7 @@ static void
Mod_LoadTexinfo (model_t *mod, bsp_t *bsp)
{
float len1, len2;
int count, miptex, i, j;
unsigned count, miptex, i, j;
mtexinfo_t *out;
texinfo_t *in;
@ -809,7 +809,7 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
dclipnode_t *in;
mclipnode_t *out;
hull_t *hull;
int count, i;
int count, i;
mod_brush_t *brush = &mod->brush;
in = bsp->clipnodes;
@ -853,7 +853,7 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
for (i = 0; i < count; i++, out++, in++) {
out->planenum = in->planenum;
if (out->planenum < 0 || out->planenum >= brush->numplanes)
if (out->planenum >= brush->numplanes)
Sys_Error ("Mod_LoadClipnodes: planenum out of bounds");
out->children[0] = in->children[0];
out->children[1] = in->children[1];
@ -913,7 +913,7 @@ Mod_MakeHull0 (model_t *mod)
static void
Mod_LoadMarksurfaces (model_t *mod, bsp_t *bsp)
{
int count, i, j;
unsigned count, i, j;
msurface_t **out;
uint32_t *in;
mod_brush_t *brush = &mod->brush;
@ -1037,7 +1037,7 @@ void
Mod_LoadBrushModel (model_t *mod, void *buffer)
{
dmodel_t *bm;
int i, j;
unsigned i, j;
bsp_t *bsp;
mod->type = mod_brush;

View file

@ -73,7 +73,7 @@ static void vulkan_brush_clear (model_t *mod, void *data)
QFV_DeviceWaitIdle (device);
for (int i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
texture_t *tx = brush->textures[i];
if (!tx) {
continue;
@ -173,7 +173,7 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
size_t image_count = 0;
size_t copy_count = 0;
size_t memsize = 0;
for (int i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
texture_t *tx = brush->textures[i];
if (!tx) {
continue;
@ -210,7 +210,7 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
qfv_packet_t *packet = QFV_PacketAcquire (stage);
buffer = QFV_PacketExtend (packet, memsize);
for (int i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
texture_t *tx = brush->textures[i];
byte *palette = vid.palette32;
if (!tx) {
@ -263,7 +263,7 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
__auto_type barriers = QFV_AllocImageBarrierSet (image_count, malloc);
barriers->size = 0;
for (int i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
texture_t *tx = brush->textures[i];
if (!tx) {
continue;
@ -281,7 +281,7 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
dfunc->vkCmdPipelineBarrier (packet->cmd, ib.srcStages, ib.dstStages,
0, 0, 0, 0, 0,
barriers->size, barriers->a);
for (int i = 0, j = 0; i < brush->numtextures; i++) {
for (unsigned i = 0, j = 0; i < brush->numtextures; i++) {
texture_t *tx = brush->textures[i];
if (!tx) {
continue;

View file

@ -92,7 +92,7 @@ typedef struct bsp29_s {
dheader_t *header;
int own_models;
int nummodels;
size_t nummodels;
dmodel_t *models;
int own_visdata;
@ -112,56 +112,55 @@ typedef struct bsp29_s {
char *entdata;
int own_leafs;
int numleafs;
size_t numleafs;
dleaf29_t *leafs;
int own_planes;
int numplanes;
size_t numplanes;
dplane_t *planes;
int own_vertexes;
int numvertexes;
size_t numvertexes;
dvertex_t *vertexes;
int own_nodes;
int numnodes;
size_t numnodes;
dnode29_t *nodes;
int own_texinfo;
int numtexinfo;
size_t numtexinfo;
texinfo_t *texinfo;
int own_faces;
int numfaces;
size_t numfaces;
dface29_t *faces;
int own_clipnodes;
int numclipnodes;
size_t numclipnodes;
dclipnode29_t *clipnodes;
int own_edges;
int numedges;
size_t numedges;
dedge29_t *edges;
int own_marksurfaces;
int nummarksurfaces;
size_t nummarksurfaces;
uint16_t *marksurfaces;
int own_surfedges;
int numsurfedges;
size_t 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 (bsp29->header) {
bsp29->header->version = LittleLong (bsp29->header->version);
for (i = 0; i < HEADER_LUMPS; i++) {
for (int i = 0; i < HEADER_LUMPS; i++) {
bsp29->header->lumps[i].fileofs =
LittleLong (bsp29->header->lumps[i].fileofs);
bsp29->header->lumps[i].filelen =
@ -170,17 +169,17 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// models
for (i=0 ; i<bsp29->nummodels ; i++) {
for (size_t i=0 ; i<bsp29->nummodels ; i++) {
d = &bsp29->models[i];
for (j=0 ; j<MAX_MAP_HULLS ; j++)
for (int 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++) {
for (int 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]);
@ -188,25 +187,25 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// vertexes
for (i=0 ; i<bsp29->numvertexes ; i++) {
for (size_t i = 0; i < bsp29->numvertexes; i++) {
dvertex_t *vertex = &bsp29->vertexes[i];
for (j=0 ; j<3 ; j++)
for (int j = 0; j < 3; j++)
vertex->point[j] = LittleFloat (vertex->point[j]);
}
// planes
for (i=0 ; i<bsp29->numplanes ; i++) {
for (size_t i = 0; i < bsp29->numplanes; i++) {
dplane_t *plane = &bsp29->planes[i];
for (j=0 ; j<3 ; j++)
for (int 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++) {
for (size_t i = 0; i < bsp29->numtexinfo; i++) {
texinfo_t *texinfo = &bsp29->texinfo[i];
for (j=0 ; j < 4 ; j++) {
for (int j = 0; j < 4; j++) {
texinfo->vecs[0][j] = LittleFloat (texinfo->vecs[0][j]);
texinfo->vecs[1][j] = LittleFloat (texinfo->vecs[1][j]);
}
@ -215,7 +214,7 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// faces
for (i=0 ; i<bsp29->numfaces ; i++) {
for (size_t i = 0; i < bsp29->numfaces; i++) {
const dface_t *face2 = &bsp2->faces[i];
dface29_t *face29 = &bsp29->faces[i];
face29->planenum = LittleShort (face2->planenum);
@ -228,11 +227,11 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// nodes
for (i=0 ; i<bsp29->numnodes ; i++) {
for (size_t 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++) {
for (int j = 0; j < 3; j++) {
node29->mins[j] = LittleShort ((int16_t) node2->mins[j]);
node29->maxs[j] = LittleShort ((int16_t) node2->maxs[j]);
}
@ -243,11 +242,11 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// leafs
for (i=0 ; i<bsp29->numleafs ; i++) {
for (size_t 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++) {
for (int j = 0; j < 3; j++) {
leaf29->mins[j] = LittleShort ((int16_t) leaf2->mins[j]);
leaf29->maxs[j] = LittleShort ((int16_t) leaf2->maxs[j]);
}
@ -260,7 +259,7 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
}
// clipnodes
for (i=0 ; i<bsp29->numclipnodes ; i++) {
for (size_t 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);
@ -272,27 +271,27 @@ swap_to_bsp29 (bsp29_t *bsp29, const bsp_t *bsp2)
if (bsp29->texdatasize) {
mtl = (dmiptexlump_t *)bsp29->texdata;
//miptexlumps have not yet been swapped
c = mtl->nummiptex;
uint32_t c = mtl->nummiptex;
mtl->nummiptex = LittleLong (mtl->nummiptex);
for (i=0 ; i<c ; i++)
for (uint32_t i = 0; i < c ; i++)
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
}
// marksurfaces
for (i=0 ; i<bsp29->nummarksurfaces ; i++) {
for (size_t 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++) {
for (size_t i = 0; i < bsp29->numsurfedges; i++) {
int32_t *surfedge = &bsp29->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
// edges
for (i=0 ; i<bsp29->numedges ; i++) {
for (size_t 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]);
@ -304,13 +303,12 @@ 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++) {
for (int i = 0; i < HEADER_LUMPS; i++) {
bsp2->header->lumps[i].fileofs =
LittleLong (bsp2->header->lumps[i].fileofs);
bsp2->header->lumps[i].filelen =
@ -321,17 +319,17 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// models
for (i=0 ; i<bsp2->nummodels ; i++) {
for (size_t i = 0; i < bsp2->nummodels; i++) {
d = &bsp2->models[i];
for (j=0 ; j<MAX_MAP_HULLS ; j++)
for (int 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++) {
for (int 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]);
@ -339,25 +337,25 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// vertexes
for (i=0 ; i<bsp2->numvertexes ; i++) {
for (size_t i = 0; i < bsp2->numvertexes; i++) {
dvertex_t *vertex = &bsp2->vertexes[i];
for (j=0 ; j<3 ; j++)
for (int j = 0; j < 3; j++)
vertex->point[j] = LittleFloat (vertex->point[j]);
}
// planes
for (i=0 ; i<bsp2->numplanes ; i++) {
for (size_t i = 0; i < bsp2->numplanes; i++) {
dplane_t *plane = &bsp2->planes[i];
for (j=0 ; j<3 ; j++)
for (int 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++) {
for (size_t i = 0; i < bsp2->numtexinfo; i++) {
texinfo_t *texinfo = &bsp2->texinfo[i];
for (j=0 ; j < 4 ; j++) {
for (int j = 0; j < 4; j++) {
texinfo->vecs[0][j] = LittleFloat (texinfo->vecs[0][j]);
texinfo->vecs[1][j] = LittleFloat (texinfo->vecs[1][j]);
}
@ -366,7 +364,7 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// faces
for (i=0 ; i<bsp2->numfaces ; i++) {
for (size_t i = 0; i < bsp2->numfaces; i++) {
dface_t *face2 = &bsp2->faces[i];
const dface29_t *face29 = &bsp29->faces[i];
face2->planenum = LittleShort (face29->planenum);
@ -379,17 +377,17 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// nodes
for (i=0 ; i<bsp2->numnodes ; i++) {
for (size_t 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++) {
for (int j = 0; j < 3; j++) {
node2->mins[j] = (int16_t) LittleShort (node29->mins[j]);
node2->maxs[j] = (int16_t) LittleShort (node29->maxs[j]);
}
for (j = 0; j < 2; j++) {
for (int j = 0; j < 2; j++) {
node2->children[j] = LittleShort (node29->children[j]);
if (node2->children[j] >= bsp2->numnodes)
if (node2->children[j] >= (int32_t) bsp2->numnodes)
node2->children[j] = (int16_t) node2->children[j];
}
node2->firstface = LittleShort (node29->firstface);
@ -397,11 +395,11 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// leafs
for (i=0 ; i<bsp2->numleafs ; i++) {
for (size_t 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++) {
for (int j = 0; j < 3; j++) {
leaf2->mins[j] = (int16_t) LittleShort (leaf29->mins[j]);
leaf2->maxs[j] = (int16_t) LittleShort (leaf29->maxs[j]);
}
@ -414,7 +412,7 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
}
// clipnodes
for (i=0 ; i<bsp2->numclipnodes ; i++) {
for (size_t i = 0; i < bsp2->numclipnodes; i++) {
dclipnode_t *clipnode2 = &bsp2->clipnodes[i];
const dclipnode29_t *clipnode29 = &bsp29->clipnodes[i];
clipnode2->planenum = LittleLong (clipnode29->planenum);
@ -425,27 +423,27 @@ swap_from_bsp29 (bsp_t *bsp2, const bsp29_t *bsp29,
// miptex
if (bsp2->texdatasize) {
mtl = (dmiptexlump_t *)bsp2->texdata;
c = LittleLong(mtl->nummiptex);
uint32_t c = LittleLong (mtl->nummiptex);
mtl->nummiptex = LittleLong (mtl->nummiptex);
for (i=0 ; i<c ; i++)
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
for (uint32_t i = 0; i < c; i++)
mtl->dataofs[i] = LittleLong (mtl->dataofs[i]);
}
// marksurfaces
for (i=0 ; i<bsp2->nummarksurfaces ; i++) {
for (size_t 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++) {
for (size_t i = 0; i < bsp2->numsurfedges; i++) {
int32_t *surfedge = &bsp2->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
// edges
for (i=0 ; i<bsp2->numedges ; i++) {
for (size_t 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]);
@ -457,13 +455,12 @@ static void
swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
void *cbdata)
{
int c, i, j;
dmiptexlump_t *mtl;
dmodel_t *d;
if (bsp->header) {
bsp->header->version = LittleLong (bsp->header->version);
for (i = 0; i < HEADER_LUMPS; i++) {
for (int i = 0; i < HEADER_LUMPS; i++) {
bsp->header->lumps[i].fileofs =
LittleLong (bsp->header->lumps[i].fileofs);
bsp->header->lumps[i].filelen =
@ -474,17 +471,17 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// models
for (i=0 ; i<bsp->nummodels ; i++) {
for (size_t i = 0; i < bsp->nummodels; i++) {
d = &bsp->models[i];
for (j=0 ; j<MAX_MAP_HULLS ; j++)
for (int 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++) {
for (int 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]);
@ -492,25 +489,25 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// vertexes
for (i=0 ; i<bsp->numvertexes ; i++) {
for (size_t i = 0; i < bsp->numvertexes; i++) {
dvertex_t *vertex = &bsp->vertexes[i];
for (j=0 ; j<3 ; j++)
for (int j = 0; j < 3; j++)
vertex->point[j] = LittleFloat (vertex->point[j]);
}
// planes
for (i=0 ; i<bsp->numplanes ; i++) {
for (size_t i = 0; i < bsp->numplanes; i++) {
dplane_t *plane = &bsp->planes[i];
for (j=0 ; j<3 ; j++)
for (int 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<bsp->numtexinfo ; i++) {
for (size_t i = 0; i < bsp->numtexinfo; i++) {
texinfo_t *texinfo = &bsp->texinfo[i];
for (j=0 ; j < 4 ; j++) {
for (int j = 0; j < 4; j++) {
texinfo->vecs[0][j] = LittleFloat (texinfo->vecs[0][j]);
texinfo->vecs[1][j] = LittleFloat (texinfo->vecs[1][j]);
}
@ -519,7 +516,7 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// faces
for (i=0 ; i<bsp->numfaces ; i++) {
for (size_t i = 0; i < bsp->numfaces; i++) {
dface_t *face = &bsp->faces[i];
face->texinfo = LittleLong (face->texinfo);
face->planenum = LittleLong (face->planenum);
@ -530,10 +527,10 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// nodes
for (i=0 ; i<bsp->numnodes ; i++) {
for (size_t i = 0; i < bsp->numnodes; i++) {
dnode_t *node = &bsp->nodes[i];
node->planenum = LittleLong (node->planenum);
for (j=0 ; j<3 ; j++) {
for (int j = 0; j < 3; j++) {
node->mins[j] = LittleFloat (node->mins[j]);
node->maxs[j] = LittleFloat (node->maxs[j]);
}
@ -544,10 +541,10 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// leafs
for (i=0 ; i<bsp->numleafs ; i++) {
for (size_t i = 0; i < bsp->numleafs; i++) {
dleaf_t *leaf = &bsp->leafs[i];
leaf->contents = LittleLong (leaf->contents);
for (j=0 ; j<3 ; j++) {
for (int j = 0; j < 3 ; j++) {
leaf->mins[j] = LittleFloat (leaf->mins[j]);
leaf->maxs[j] = LittleFloat (leaf->maxs[j]);
}
@ -558,7 +555,7 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
}
// clipnodes
for (i=0 ; i<bsp->numclipnodes ; i++) {
for (size_t i = 0; i < bsp->numclipnodes; i++) {
dclipnode_t *clipnode = &bsp->clipnodes[i];
clipnode->planenum = LittleLong (clipnode->planenum);
clipnode->children[0] = LittleLong (clipnode->children[0]);
@ -567,30 +564,31 @@ swap_bsp (bsp_t *bsp, int todisk, void (*cb) (const bsp_t *, void *),
// miptex
if (bsp->texdatasize) {
mtl = (dmiptexlump_t *)bsp->texdata;
mtl = (dmiptexlump_t *) bsp->texdata;
uint32_t c;
if (todisk)
c = mtl->nummiptex;
else
c = LittleLong(mtl->nummiptex);
mtl->nummiptex = LittleLong (mtl->nummiptex);
for (i=0 ; i<c ; i++)
for (uint32_t i = 0; i < c; i++)
mtl->dataofs[i] = LittleLong(mtl->dataofs[i]);
}
// marksurfaces
for (i=0 ; i<bsp->nummarksurfaces ; i++) {
for (size_t i = 0; i < bsp->nummarksurfaces; i++) {
uint32_t *marksurface = &bsp->marksurfaces[i];
*marksurface = LittleLong (*marksurface);
}
// surfedges
for (i=0 ; i<bsp->numsurfedges ; i++) {
for (size_t i = 0; i < bsp->numsurfedges; i++) {
int32_t *surfedge = &bsp->surfedges[i];
*surfedge = LittleLong (*surfedge);
}
// edges
for (i=0 ; i<bsp->numedges ; i++) {
for (size_t i = 0; i < bsp->numedges; i++) {
dedge_t *edge = &bsp->edges[i];
edge->v[0] = LittleLong (edge->v[0]);
edge->v[1] = LittleLong (edge->v[1]);

View file

@ -549,9 +549,8 @@ gl_R_BlendLightmaps (void)
void
gl_overbright_f (cvar_t *var)
{
int num, i, j;
int num;
model_t *m;
msurface_t *surf;
entity_t *ent;
mod_brush_t *brush;
@ -608,8 +607,8 @@ gl_overbright_f (cvar_t *var)
continue;
brush = &m->brush;
for (j = 0, surf = brush->surfaces; j < brush->numsurfaces;
j++, surf++) {
for (unsigned j = 0; j < brush->numsurfaces; j++) {
msurface_t *surf = brush->surfaces + j;
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
continue;
@ -626,7 +625,8 @@ gl_overbright_f (cvar_t *var)
brush = &r_worldentity.renderer.model->brush;
for (i = 0, surf = brush->surfaces; i < brush->numsurfaces; i++, surf++) {
for (unsigned i = 0; i < brush->numsurfaces; i++) {
msurface_t *surf = brush->surfaces + i;
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
continue;
@ -709,7 +709,6 @@ GL_CreateSurfaceLightmap (mod_brush_t *brush, msurface_t *surf)
void
GL_BuildLightmaps (model_t **models, int num_models)
{
int i, j;
model_t *m;
mod_brush_t *brush;
@ -750,7 +749,7 @@ GL_BuildLightmaps (model_t **models, int num_models)
break;
}
for (j = 1; j < num_models; j++) {
for (int j = 1; j < num_models; j++) {
m = models[j];
if (!m)
break;
@ -762,7 +761,7 @@ GL_BuildLightmaps (model_t **models, int num_models)
r_pcurrentvertbase = brush->vertexes;
gl_currentmodel = m;
// non-bsp models don't have surfaces.
for (i = 0; i < brush->numsurfaces; i++) {
for (unsigned i = 0; i < brush->numsurfaces; i++) {
if (brush->surfaces[i].flags & SURF_DRAWTURB)
continue;
if (gl_sky_divide->int_val && (brush->surfaces[i].flags &
@ -774,7 +773,7 @@ GL_BuildLightmaps (model_t **models, int num_models)
}
// upload all lightmaps that were filled
for (i = 0; i < MAX_LIGHTMAPS; i++) {
for (int i = 0; i < MAX_LIGHTMAPS; i++) {
if (!allocated[i][0])
break; // no more used
gl_lightmap_modified[i] = false;

View file

@ -170,10 +170,9 @@ gl_R_Init (void)
static void
register_textures (mod_brush_t *brush)
{
int i;
texture_t *tex;
for (i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
tex = brush->textures[i];
if (!tex)
continue;
@ -211,7 +210,7 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
// identify sky texture
gl_mirrortexturenum = -1;
gl_R_ClearTextures ();
for (int i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
tex = brush->textures[i];
if (!tex)
continue;

View file

@ -160,12 +160,10 @@ gl_R_AddTexture (texture_t *tx)
void
gl_R_InitSurfaceChains (mod_brush_t *brush)
{
int i;
if (static_chains)
free (static_chains);
static_chains = calloc (brush->nummodelsurfaces, sizeof (instsurf_t));
for (i = 0; i < brush->nummodelsurfaces; i++)
for (unsigned i = 0; i < brush->nummodelsurfaces; i++)
brush->surfaces[i].instsurf = static_chains + i;
release_instsurfs ();
@ -527,8 +525,6 @@ void
gl_R_DrawBrushModel (entity_t *e)
{
float dot, radius;
int i;
unsigned int k;
msurface_t *surf;
qboolean rotated;
vec3_t mins, maxs;
@ -581,7 +577,7 @@ gl_R_DrawBrushModel (entity_t *e)
if (brush->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
vec3_t lightorigin;
for (k = 0; k < r_maxdlights; k++) {
for (unsigned k = 0; k < r_maxdlights; k++) {
if ((r_dlights[k].die < vr_data.realtime)
|| (!r_dlights[k].radius))
continue;
@ -600,7 +596,7 @@ gl_R_DrawBrushModel (entity_t *e)
surf = &brush->surfaces[brush->firstmodelsurface];
// draw texture
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
for (unsigned i = 0; i < brush->nummodelsurfaces; i++, surf++) {
// find which side of the node we are on
plane_t *plane = surf->plane;

View file

@ -325,12 +325,10 @@ glsl_R_AddTexture (texture_t *tx)
static void
glsl_R_InitSurfaceChains (mod_brush_t *brush)
{
int i;
release_static_instsurfs ();
release_instsurfs ();
for (i = 0; i < brush->nummodelsurfaces; i++) {
for (unsigned i = 0; i < brush->nummodelsurfaces; i++) {
brush->surfaces[i].instsurf = get_static_instsurf ();
brush->surfaces[i].instsurf->surface = &brush->surfaces[i];
}
@ -414,10 +412,9 @@ chain_surface (glslbspctx_t *bctx, msurface_t *surf)
static void
register_textures (mod_brush_t *brush)
{
int i;
texture_t *tex;
for (i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
tex = brush->textures[i];
if (!tex)
continue;
@ -553,7 +550,6 @@ build_surf_displist (model_t **models, msurface_t *surf, int base,
void
glsl_R_BuildDisplayLists (model_t **models, int num_models)
{
int i, j;
int vertex_index_base;
model_t *m;
dmodel_t *dm;
@ -571,7 +567,7 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
// now run through all surfaces, chaining them to their textures, thus
// effectively sorting the surfaces by texture (without worrying about
// surface order on the same texture chain).
for (i = 0; i < num_models; i++) {
for (int i = 0; i < num_models; i++) {
m = models[i];
if (!m)
continue;
@ -581,7 +577,7 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
brush = &m->brush;
// non-bsp models don't have surfaces.
dm = brush->submodels;
for (j = 0; j < brush->numsurfaces; j++) {
for (uint32_t j = 0; j < brush->numsurfaces; j++) {
glsltex_t *tex;
if (j == dm->firstface + dm->numfaces) {
dm++;
@ -608,7 +604,7 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
// Run through the textures, using their chains to build display maps.
// For animated textures, if a surface is on one texture of the group, it
// will be on all.
for (i = 0; i < r_num_texture_chains; i++) {
for (int i = 0; i < r_num_texture_chains; i++) {
glsltex_t *tex;
instsurf_t *is;
elechain_t *ec = 0;
@ -663,7 +659,6 @@ static void
R_DrawBrushModel (entity_t *e)
{
float dot, radius;
int i;
unsigned k;
model_t *model = e->renderer.model;
mod_brush_t *brush = &model->brush;
@ -722,7 +717,7 @@ R_DrawBrushModel (entity_t *e)
surf = &brush->surfaces[brush->firstmodelsurface];
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
for (unsigned i = 0; i < brush->nummodelsurfaces; i++, surf++) {
// find the node side on which we are
plane = surf->plane;

View file

@ -203,7 +203,7 @@ create_surf_lightmap (msurface_t *surf)
void
glsl_R_BuildLightmaps (model_t **models, int num_models)
{
int i, j, size;
int size;
model_t *m;
mod_brush_t *brush;
@ -216,7 +216,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
glsl_R_BuildLightMap = R_BuildLightMap_1;
bl_extents[1] = bl_extents[0] = 0;
for (j = 1; j < num_models; j++) {
for (int j = 1; j < num_models; j++) {
m = models[j];
if (!m)
break;
@ -226,7 +226,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
}
brush = &m->brush;
// non-bsp models don't have surfaces.
for (i = 0; i < brush->numsurfaces; i++) {
for (unsigned i = 0; i < brush->numsurfaces; i++) {
msurface_t *surf = brush->surfaces + i;
surf->lightpic = 0; // paranoia
if (surf->flags & SURF_DRAWTURB)
@ -238,7 +238,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
}
size = bl_extents[0] * bl_extents[1] * 3; // * 3 for rgb support
blocklights = realloc (blocklights, size * sizeof (blocklights[0]));
for (j = 1; j < num_models; j++) {
for (int j = 1; j < num_models; j++) {
m = models[j];
if (!m)
break;
@ -248,7 +248,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
}
brush = &m->brush;
// non-bsp models don't have surfaces.
for (i = 0; i < brush->numsurfaces; i++) {
for (unsigned i = 0; i < brush->numsurfaces; i++) {
msurface_t *surf = brush->surfaces + i;
if (surf->lightpic)
glsl_R_BuildLightMap (0, brush, surf);

View file

@ -171,12 +171,11 @@ static void
init_surface_chains (mod_brush_t *brush, vulkan_ctx_t *ctx)
{
bspctx_t *bctx = ctx->bsp_context;
int i;
release_static_instsurfs (bctx);
release_instsurfs (bctx);
for (i = 0; i < brush->nummodelsurfaces; i++) {
for (unsigned i = 0; i < brush->nummodelsurfaces; i++) {
brush->surfaces[i].instsurf = get_static_instsurf (bctx);
brush->surfaces[i].instsurf->surface = &brush->surfaces[i];
}
@ -242,10 +241,9 @@ chain_surface (msurface_t *surf, vulkan_ctx_t *ctx)
static void
register_textures (mod_brush_t *brush, vulkan_ctx_t *ctx)
{
int i;
texture_t *tex;
for (i = 0; i < brush->numtextures; i++) {
for (unsigned i = 0; i < brush->numtextures; i++) {
tex = brush->textures[i];
if (!tex)
continue;
@ -394,7 +392,6 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
bspctx_t *bctx = ctx->bsp_context;
int i, j;
int vertex_index_base;
model_t *m;
dmodel_t *dm;
@ -414,7 +411,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
// run through all surfaces, chaining them to their textures, thus
// effectively sorting the surfaces by texture (without worrying about
// surface order on the same texture chain).
for (i = 0; i < num_models; i++) {
for (int i = 0; i < num_models; i++) {
m = models[i];
if (!m)
continue;
@ -424,7 +421,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
continue;
brush = &m->brush;
dm = brush->submodels;
for (j = 0; j < brush->numsurfaces; j++) {
for (unsigned j = 0; j < brush->numsurfaces; j++) {
vulktex_t *tex;
if (j == dm->firstface + dm->numfaces) {
// move on to the next sub-model
@ -581,7 +578,6 @@ static void
R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
{
float dot, radius;
int i;
model_t *model;
plane_t *plane;
msurface_t *surf;
@ -625,7 +621,7 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
surf = &brush->surfaces[brush->firstmodelsurface];
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
for (unsigned i = 0; i < brush->nummodelsurfaces; i++, surf++) {
// find the node side on which we are
plane = surf->plane;

View file

@ -1105,7 +1105,6 @@ SV_SpawnServer (const char *server)
{
byte *buf;
QFile *ent_file;
int i;
edict_t *ent;
@ -1162,7 +1161,7 @@ SV_SpawnServer (const char *server)
// leave slots at start for only clients
sv.num_edicts = svs.maxclients + 1;
for (i = 0; i < svs.maxclients; i++) {
for (int i = 0; i < svs.maxclients; i++) {
ent = EDICT_NUM (&sv_pr_state, i + 1);
svs.clients[i].edict = ent;
}
@ -1190,7 +1189,7 @@ SV_SpawnServer (const char *server)
sv.model_precache[0] = sv_pr_state.pr_strings;
sv.model_precache[1] = sv.modelname;
for (i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
for (unsigned i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
sv.model_precache[1 + i] = localmodels[i];
sv.models[i + 1] = Mod_ForName (localmodels[i], false);
}
@ -1244,10 +1243,12 @@ SV_SpawnServer (const char *server)
sv.signon.cursize);
// send serverinfo to all connected clients
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++,
host_client++)
if (host_client->active)
for (int i = 0; i < svs.maxclients; i++) {
host_client = svs.clients + i;
if (host_client->active) {
SV_SendServerinfo (host_client);
}
}
Sys_MaskPrintf (SYS_dev, "Server spawned.\n");
S_UnblockSound ();

View file

@ -320,7 +320,6 @@ SV_SpawnServer (const char *server)
{
byte *buf;
edict_t *ent;
int i;
void *so_buffers;
int *so_sizes;
int max_so;
@ -384,7 +383,7 @@ SV_SpawnServer (const char *server)
// leave slots at start for only clients
sv.num_edicts = MAX_CLIENTS + 1;
for (i = 0; i < MAX_CLIENTS; i++) {
for (int i = 0; i < MAX_CLIENTS; i++) {
ent = EDICT_NUM (&sv_pr_state, i + 1);
svs.clients[i].edict = ent;
// ZOID - make sure we update frags right
@ -407,7 +406,7 @@ SV_SpawnServer (const char *server)
sv.model_precache[0] = sv_pr_state.pr_strings;
sv.model_precache[1] = sv.modelname;
sv.models[1] = sv.worldmodel;
for (i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
for (unsigned i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
sv.model_precache[1 + i] = localmodels[i];
sv.models[i + 1] = Mod_ForName (localmodels[i], false);
}

View file

@ -531,7 +531,7 @@ create_image (long width, long height)
static image_t *
render_map (bsp_t *bsp)
{
long i = 0, j = 0, k = 0, x = 0;
long j = 0, k = 0, x = 0;
dvertex_t *vertexlist, *vert1, *vert2;
dedge_t *edgelist;
@ -567,14 +567,14 @@ render_map (bsp_t *bsp)
exit (2);
}
/* initialize the array */
for (i = 0; i < bsp->numedges; i++) {
for (unsigned i = 0; i < bsp->numedges; i++) {
edge_extra[i].num_face_ref = 0;
for (j = 0; j < MAX_REF_FACES; j++) {
for (int j = 0; j < MAX_REF_FACES; j++) {
edge_extra[i].ref_faces[j] = -1;
}
}
for (i = 0; i < bsp->numfaces; i++) {
for (unsigned i = 0; i < bsp->numfaces; i++) {
/* calculate the normal (cross product) */
/* starting edge: edgelist[ledges[facelist[i].firstedge]] */
/* number of edges: facelist[i].numedges; */
@ -647,7 +647,7 @@ render_map (bsp_t *bsp)
printf ("Collecting min/max\n");
/* Collect min and max */
for (i = 0; i < bsp->numvertexes; i++) {
for (unsigned i = 0; i < bsp->numvertexes; i++) {
/* Ugly hack - flip stuff around for different camera angles */
switch (options.camera_axis) {
@ -788,7 +788,7 @@ render_map (bsp_t *bsp)
fprintf (stderr, "Plotting edges...");
k = 0;
drawcol = (options.edgeremove) ? 64 : 32;
for (i = 0; i < bsp->numedges; i++) {
for (unsigned i = 0; i < bsp->numedges; i++) {
/* Do a check on this line ... see if we keep this line or not */
/* run through all referenced faces */
@ -840,7 +840,7 @@ render_map (bsp_t *bsp)
}
}
printf ("%d edges plotted", bsp->numedges);
printf ("%zd edges plotted", bsp->numedges);
if (options.edgeremove) {
printf (" (%ld edges removed)\n", k);
} else {
@ -848,7 +848,7 @@ render_map (bsp_t *bsp)
}
/* Little gradient */
for (i = 0; i <= 255; i++) {
for (unsigned i = 0; i <= 255; i++) {
// across from top left
plotpoint (image, i, 0, 255 - i);
// down from top left
@ -872,8 +872,8 @@ render_map (bsp_t *bsp)
/* Negate image if necessary */
if (options.negative_image) {
for (i = 0; i < image->height; i++) {
for (j = 0; j < image->width; j++) {
for (int i = 0; i < image->height; i++) {
for (int j = 0; j < image->width; j++) {
image->image[i * image->width + j] =
255 - image->image[i * image->width + j];
}

View file

@ -50,7 +50,7 @@ bspinfo ()
lump->fileofs, lump->filelen, lump->filelen / info->size);
}
for (int i = 0; i < bsp->nummodels; i++) {
for (unsigned i = 0; i < bsp->nummodels; i++) {
dmodel_t *model = &bsp->models[i];
printf ("model: *%d\n", i);
printf (" mins : [%g, %g, %g]\n", VectorExpand (model->mins));

View file

@ -122,10 +122,11 @@ FindMiptex (const char *name)
static int
FindTexinfo (texinfo_t *t)
{
int i, j;
size_t i;
int j;
texinfo_t *tex;
if (t->miptex < 0)
if (t->miptex == ~0u)
return t->miptex; // it's HINT or SKIP
// set the special flag
@ -545,7 +546,7 @@ LoadMapFile (const char *filename)
qprintf ("%5i brushes (%i detail)\n", nummapbrushes, numdetailbrushes);
qprintf ("%5i entities\n", num_entities);
qprintf ("%5i textures\n", nummiptexnames);
qprintf ("%5i texinfo\n", bsp->numtexinfo);
qprintf ("%5zd texinfo\n", bsp->numtexinfo);
}
void

View file

@ -103,7 +103,7 @@ ProcessEntity (int entnum)
worldmodel = false;
if (entnum == 1)
qprintf ("--- Internal Entities ---\n");
sprintf (mod, "*%i", bsp->nummodels);
sprintf (mod, "*%zd", bsp->nummodels);
if (options.verbosity)
PrintEntity (ent);
@ -225,7 +225,6 @@ WriteClipHull (void)
FILE *f;
dclipnode_t *d;
dplane_t *p;
int i;
options.hullfile[strlen (options.hullfile) - 1] = '0' + hullnum;
@ -236,18 +235,18 @@ WriteClipHull (void)
if (!f)
Sys_Error ("Couldn't open %s", options.hullfile);
fprintf (f, "%i\n", bsp->nummodels);
fprintf (f, "%zd\n", bsp->nummodels);
for (i = 0; i < bsp->nummodels; i++)
for (size_t i = 0; i < bsp->nummodels; i++)
fprintf (f, "%i\n", bsp->models[i].headnode[hullnum]);
fprintf (f, "\n%i\n", bsp->numclipnodes);
fprintf (f, "\n%zd\n", bsp->numclipnodes);
for (i = 0; i < bsp->numclipnodes; i++) {
for (size_t i = 0; i < bsp->numclipnodes; i++) {
d = &bsp->clipnodes[i];
p = &bsp->planes[d->planenum];
// the node number is written out only for human readability
fprintf (f, "%5i : %f %f %f %f : %5i %5i\n", i, p->normal[0],
fprintf (f, "%5zd : %f %f %f %f : %5i %5i\n", i, p->normal[0],
p->normal[1], p->normal[2], p->dist, d->children[0],
d->children[1]);
}
@ -268,7 +267,8 @@ ReadClipHull (int hullnum)
plane_t p;
dplane_t dp;
float f1, f2, f3, f4;
int firstclipnode, junk, c1, c2, i, j, n;
int firstclipnode, junk, c1, c2;
size_t i, j, n;
int flip;
options.hullfile[strlen (options.hullfile) - 1] = '0' + hullnum;
@ -277,21 +277,21 @@ ReadClipHull (int hullnum)
if (!f)
Sys_Error ("Couldn't open %s", options.hullfile);
if (fscanf (f, "%d\n", &n) != 1)
if (fscanf (f, "%zd\n", &n) != 1)
Sys_Error ("Error parsing %s", options.hullfile);
if (n != bsp->nummodels)
Sys_Error ("ReadClipHull: hull had %i models, base had %i", n,
Sys_Error ("ReadClipHull: hull had %zd models, base had %zd", n,
bsp->nummodels);
for (i = 0; i < n; i++) {
if (fscanf (f, "%d\n", &j) != 1)
if (fscanf (f, "%zd\n", &j) != 1)
Sys_Error ("Error parsing %s", options.hullfile);
bsp->models[i].headnode[hullnum] = bsp->numclipnodes + j;
}
if (fscanf (f, "\n%d\n", &n) != 1)
if (fscanf (f, "\n%zd\n", &n) != 1)
Sys_Error ("Error parsing %s", options.hullfile);
firstclipnode = bsp->numclipnodes;

View file

@ -102,10 +102,9 @@ load_planes (void)
{
const dplane_t *p;
plane_t tp = { };
int i;
planes.size = 0;
for (i = 0; i < bsp->numplanes; i++) {
for (size_t i = 0; i < bsp->numplanes; i++) {
p = bsp->planes + i;
VectorCopy (p->normal, tp.normal);
tp.dist = p->dist;
@ -124,11 +123,10 @@ static void
load_faces (void)
{
const dface_t *f;
int i, j;
winding_t *points;
mfaces = calloc (bsp->numfaces, sizeof (face_t));
for (i = 0; i < bsp->numfaces; i++) {
for (size_t i = 0; i < bsp->numfaces; i++) {
f = bsp->faces + i;
mfaces[i].planenum = f->planenum;
mfaces[i].planeside = f->side;
@ -138,7 +136,7 @@ load_faces (void)
points = mfaces[i].points;
points->numpoints = f->numedges;
for (j = 0; j < points->numpoints; j++) {
for (int j = 0; j < points->numpoints; j++) {
int e = mfaces[i].edges[j];
int v;
@ -162,11 +160,9 @@ static void
load_leafs (void)
{
const dleaf_t *l;
int i;
unsigned j;
leafs = calloc (bsp->numleafs, sizeof (node_t));
for (i = 0; i < bsp->numleafs; i++) {
for (size_t i = 0; i < bsp->numleafs; i++) {
l = bsp->leafs + i;
leafs[i].planenum = -1;
leafs[i].contents = l->contents;
@ -174,7 +170,7 @@ load_leafs (void)
VectorCopy (l->maxs, leafs[i].maxs);
leafs[i].markfaces = calloc (l->nummarksurfaces + 1,
sizeof (face_t *));
for (j = 0; j < l->nummarksurfaces; j++) {
for (uint32_t j = 0; j < l->nummarksurfaces; j++) {
unsigned short ms = l->firstmarksurface + j;
leafs[i].markfaces[j] = mfaces + marksurfaces[ms];
}
@ -185,19 +181,16 @@ static void
load_nodes (void)
{
const dnode_t *n;
face_t *f;
int i;
unsigned j;
nodes = calloc (bsp->numnodes, sizeof (node_t));
for (i = 0; i < bsp->numnodes; i++) {
for (size_t i = 0; i < bsp->numnodes; i++) {
n = bsp->nodes + i;
VectorCopy (n->mins, nodes[i].mins);
VectorCopy (n->maxs, nodes[i].maxs);
nodes[i].planenum = n->planenum;
nodes[i].firstface = n->firstface;
nodes[i].numfaces = n->numfaces;
for (j = 0; j < 2; j++) {
for (int j = 0; j < 2; j++) {
if (n->children[j] < 0) {
nodes[i].children[j] = leafs - n->children[j] - 1;
} else {
@ -206,7 +199,8 @@ load_nodes (void)
}
if (nodes[i].numfaces) {
nodes[i].faces = mfaces + nodes[i].firstface;
for (j = 0, f = nodes[i].faces; j < n->numfaces - 1; j++, f++) {
for (uint32_t j = 0; j < n->numfaces - 1; j++) {
face_t *f = nodes[i].faces + j;
f->next = f + 1;
}
}
@ -375,7 +369,7 @@ extract_textures (void)
{
const dmiptexlump_t *miptexlump = (dmiptexlump_t *) bsp->texdata;
miptex_t *miptex;
int i, mtsize, pixels;
int mtsize, pixels;
const char *wadfile;
wad_t *wad;
const char *uname;
@ -387,15 +381,15 @@ extract_textures (void)
wad_add_data (wad, "PALETTE", TYP_PALETTE, default_palette,
sizeof (default_palette));
for (i = 0; i < miptexlump->nummiptex; i++) {
if (miptexlump->dataofs[i] == -1)
for (size_t i = 0; i < miptexlump->nummiptex; i++) {
if (miptexlump->dataofs[i] == ~0u)
continue;
miptex = (miptex_t *)(bsp->texdata + miptexlump->dataofs[i]);
pixels = miptex->width * miptex->height / 64 * 85;
mtsize = sizeof (miptex_t) + pixels;
uname = unique_name (wad, miptex->name);
#if 1
printf ("%3d %6d ", i, miptexlump->dataofs[i]);
printf ("%3zd %6d ", i, miptexlump->dataofs[i]);
printf ("%16.16s %16.16s %3dx%-3d %d %d %d %d %d %d\n",
miptex->name, uname, miptex->width,
miptex->height, miptex->offsets[0], miptex->offsets[1],
@ -432,7 +426,6 @@ extract_hull (void)
{
// hullfile = output_file (".c");
const char *hullfile;
int i, j;
QFile *hf;
hullfile = output_file (".c");
@ -441,14 +434,14 @@ extract_hull (void)
else
hf = Qopen (hullfile, "wt");
printf ("%d\n", bsp->nummodels);
for (i = 0; i < bsp->nummodels; i++) {
printf ("%zd\n", bsp->nummodels);
for (size_t i = 0; i < bsp->nummodels; i++) {
dmodel_t *m = bsp->models + i;
printf ("mins: (%g, %g, %g)\n", m->mins[0], m->mins[1], m->mins[2]);
printf ("maxs: (%g, %g, %g)\n", m->maxs[0], m->maxs[1], m->maxs[2]);
printf ("origin: (%g, %g, %g)\n",
m->origin[0], m->origin[1], m->origin[2]);
for (j = 0; j < MAX_MAP_HULLS; j++)
for (int j = 0; j < MAX_MAP_HULLS; j++)
printf ("headnodes[%d]: %d\n", j, m->headnode[j]);
printf ("visleafs: %d\n", m->visleafs);
printf ("firstface: %d\n", m->firstface);
@ -456,7 +449,7 @@ extract_hull (void)
printf ("\n");
}
Qprintf (hf, "dclipnode_t clipnodes[] = {\n");
for (i = 0; i < bsp->numnodes; i++) {
for (size_t i = 0; i < bsp->numnodes; i++) {
int c0, c1;
c0 = bsp->nodes[i].children[0];
c1 = bsp->nodes[i].children[1];
@ -464,13 +457,13 @@ extract_hull (void)
c0 = bsp->leafs[-1 - c0].contents;
if (c1 < 0)
c1 = bsp->leafs[-1 - c1].contents;
Qprintf (hf, "\t{%d, {%d, %d}},\t// %d\n", bsp->nodes[i].planenum,
Qprintf (hf, "\t{%d, {%d, %d}},\t// %zd\n", bsp->nodes[i].planenum,
c0, c1, i);
}
Qprintf (hf, "};\n");
Qprintf (hf, "mplane_t planes[] = {\n");
for (i = 0; i < bsp->numplanes; i++) {
Qprintf (hf, "\t{{%g, %g, %g}, %g, %d, 0, {0, 0}},\t// %d\n",
for (size_t i = 0; i < bsp->numplanes; i++) {
Qprintf (hf, "\t{{%g, %g, %g}, %g, %d, 0, {0, 0}},\t// %zd\n",
bsp->planes[i].normal[0], bsp->planes[i].normal[1],
bsp->planes[i].normal[2],
bsp->planes[i].dist, bsp->planes[i].type,

View file

@ -163,21 +163,19 @@ RecursiveGrowRegion (dface_t *r, face_t *f)
static void
CountRealNumbers (void)
{
int c, i;
qprintf ("%5zd regions\n", bsp->numfaces - firstmodelface);
qprintf ("%5i regions\n", bsp->numfaces - firstmodelface);
c = 0;
for (i = firstmodelface; i < bsp->numfaces; i++)
size_t c = 0;
for (size_t i = firstmodelface; i < bsp->numfaces; i++)
c += bsp->faces[i].numedges;
qprintf ("%5i real marksurfaces\n", c);
qprintf ("%5zd real marksurfaces\n", c);
c = 0;
for (i = firstmodeledge; i < bsp->numedges; i++)
for (size_t i = firstmodeledge; i < bsp->numedges; i++)
if (edgefaces[i].f[0])
c++; // not removed
qprintf ("%5i real edges\n", c);
qprintf ("%5zd real edges\n", c);
}
static void

View file

@ -204,7 +204,7 @@ int c_cornerverts;
static PR_RESMAP (hashvert_t) hvertex;
#define EDGEFACE_CHUNK 4096
int numedgefaces = 0;
size_t numedgefaces = 0;
edgeface_t *edgefaces = 0;
int firstmodeledge = 1;
int firstmodelface;
@ -336,12 +336,12 @@ int c_tryedges;
\return The edge number. For a re-used edge, the edge number will
be negative, indicating the ends of the edge are reversed.
*/
static int
static size_t
GetEdge (const vec3_t p1, const vec3_t p2, face_t *f)
{
dedge_t edge;
unsigned v1, v2;
int i;
size_t i;
if (!f->contents[0])
Sys_Error ("GetEdge: 0 contents");

View file

@ -53,10 +53,8 @@ int firstface;
int
FindFinalPlane (const dplane_t *p)
{
const dplane_t *dplane;
int i;
for (i = 0, dplane = bsp->planes; i < bsp->numplanes; i++, dplane++) {
for (size_t i = 0; i < bsp->numplanes; i++) {
const dplane_t *dplane = bsp->planes + i;
if (p->type != dplane->type)
continue;
if (p->dist != dplane->dist)

View file

@ -71,7 +71,7 @@ get_tex_name (int texindex)
if (bsp->texdatasize) {
mtl = (dmiptexlump_t *) bsp->texdata;
miptex = bsp->texinfo[texindex].miptex;
if (mtl->dataofs[miptex] != -1) {
if (mtl->dataofs[miptex] != ~0u) {
mt = (miptex_t *) (bsp->texdata + mtl->dataofs[miptex]);
return mt->name;
}
@ -172,7 +172,6 @@ CalcFaceVectors (lightinfo_t *l, vec3_t faceorg)
static void
CalcFaceExtents (lightinfo_t *l)
{
int i, j, e;
vec_t mins[2], maxs[2], val;
dface_t *s;
dvertex_t *v;
@ -185,14 +184,14 @@ CalcFaceExtents (lightinfo_t *l)
tex = &bsp->texinfo[s->texinfo];
for (i = 0; i < s->numedges; i++) {
e = bsp->surfedges[s->firstedge + i];
for (uint32_t i = 0; i < s->numedges; i++) {
int e = bsp->surfedges[s->firstedge + i];
if (e >= 0)
v = bsp->vertexes + bsp->edges[e].v[0];
else
v = bsp->vertexes + bsp->edges[-e].v[1];
for (j = 0; j < 2; j++) {
for (int j = 0; j < 2; j++) {
val = DotProduct (v->point, tex->vecs[j]) + tex->vecs[j][3];
if (val < mins[j])
mins[j] = val;
@ -201,7 +200,7 @@ CalcFaceExtents (lightinfo_t *l)
}
}
for (i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
l->exactmins[i] = mins[i];
l->exactmaxs[i] = maxs[i];

View file

@ -71,7 +71,7 @@ dstring_t *lightdata;
dstring_t *rgblightdata;
dmodel_t *bspmodel;
int bspfileface; // next surface to dispatch
size_t bspfileface; // next surface to dispatch
int bspfileent; // next entity to dispatch
vec3_t bsp_origin;
@ -119,13 +119,13 @@ VisThread (void *junk)
static void *
LightThread (void *l)
{
int i;
size_t i;
while (1) {
LOCK;
i = bspfileface++;
if (i < bsp->numfaces) {
printf ("%5d / %d\r", i, bsp->numfaces);
printf ("%5zd / %zd\r", i, bsp->numfaces);
fflush (stdout);
}
UNLOCK;
@ -139,22 +139,21 @@ LightThread (void *l)
static void
FindFaceOffsets (void)
{
int i, j;
entity_t *ent;
vec3_t org;
const char *name;
surfaceorgs = (vec3_t *) calloc (bsp->numfaces, sizeof (vec3_t));
for (i = 1; i < bsp->nummodels; i++) {
ent = FindEntityWithKeyPair ("model", name = va (0, "*%d", i));
for (size_t i = 1; i < bsp->nummodels; i++) {
ent = FindEntityWithKeyPair ("model", name = va (0, "*%zd", i));
VectorZero (org);
if (!ent)
Sys_Error ("FindFaceOffsets: Couldn't find entity for model %s.\n",
name);
if (!strncmp (ValueForKey (ent, "classname"), "rotate_", 7))
GetVectorForKey (ent, "origin", org);
for (j = 0; j < bsp->models[i].numfaces; j++)
for (uint32_t j = 0; j < bsp->models[i].numfaces; j++)
VectorCopy (org, surfaceorgs[bsp->models[i].firstface]);
}
}

View file

@ -145,9 +145,6 @@ VisEntity (int ent_index)
entity_t *entity = entities + ent_index;
dleaf_t *leaf;
int ignorevis = false;
int i;
unsigned j;
uint32_t *mark;
byte *vis, *surfacehit;
int vis_size;
@ -193,19 +190,19 @@ VisEntity (int ent_index)
memset (surfacehit, 0, (bsp->numfaces + 7) / 8);
DecompressVis (bsp->visdata + leaf->visofs, vis, vis_size);
for (i = 0, leaf = bsp->leafs + 1; i < bsp->models[0].visleafs;
i++, leaf++) {
for (uint32_t i = 0; i < bsp->models[0].visleafs; i++) {
leaf = bsp->leafs + 1 + i;
if (!leaf->nummarksurfaces)
continue;
if (vis[i >> 3] & (1 << (i & 7))) {
for (j = 0, mark = bsp->marksurfaces + leaf->firstmarksurface;
j < leaf->nummarksurfaces; j++, mark++) {
mark_face (*mark, surfacehit, entity);
uint32_t *mark = bsp->marksurfaces + leaf->firstmarksurface;
for (size_t j = 0; j < leaf->nummarksurfaces; j++) {
mark_face (*mark++, surfacehit, entity);
}
}
}
for (i = 1; i < bsp->nummodels; i++) {
for (j = 0; (int) j < bsp->models[i].numfaces; j++) {
for (size_t i = 1; i < bsp->nummodels; i++) {
for (uint32_t j = 0; j < bsp->models[i].numfaces; j++) {
//FIXME vis
mark_face (bsp->models[i].firstface + j, surfacehit, entity);
}
@ -216,8 +213,6 @@ VisEntity (int ent_index)
void
VisStats (void)
{
int i, count;
printf ("%4i lights\n", counts.lights);
printf ("%4i air\n", counts.empty);
printf ("%4i solid\n", counts.solid);
@ -227,10 +222,11 @@ VisStats (void)
printf ("%4i sky\n", counts.sky);
printf ("%4i unknown\n", counts.misc);
for (i = count = 0; i < bsp->numfaces; i++)
size_t count = 0;
for (size_t i = 0; i < bsp->numfaces; i++)
if (surfacelightchain[i])
count++;
printf ("%i faces, %i (%i%%) may receive light\n", bsp->numfaces,
printf ("%zd faces, %zd (%zd%%) may receive light\n", bsp->numfaces,
count, count * 100 / bsp->numfaces);
if (counts.solid || counts.sky)
printf ("warning: %i lights of %i lights (%i%%) were found in sky\n"
@ -238,6 +234,6 @@ VisStats (void)
"out of the solid or sky to accelerate compiling\n",
counts.solid + counts.sky, counts.lights,
(counts.solid + counts.sky) * 100 / counts.lights);
printf ("%i lights will be cast onto %i surfaces, %i casts will "
printf ("%i lights will be cast onto %zd surfaces, %i casts will "
"be performed\n", counts.lights, bsp->numfaces, counts.cast);
}

View file

@ -70,21 +70,20 @@ static byte *surf_ambients;
static void
SurfaceBBox (dface_t *s, vec3_t mins, vec3_t maxs)
{
int vi, e, i, j;
float *v;
mins[0] = mins[1] = mins[2] = 999999;
maxs[0] = maxs[1] = maxs[2] = -99999;
for (i = 0; i < s->numedges; i++) {
e = bsp->surfedges[s->firstedge + i];
for (uint32_t i = 0; i < s->numedges; i++) {
int e = bsp->surfedges[s->firstedge + i];
int vi;
if (e >= 0)
vi = bsp->edges[e].v[0];
else
vi = bsp->edges[-e].v[1];
v = bsp->vertexes[vi].point;
float *v = bsp->vertexes[vi].point;
for (j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
if (v[j] < mins[j])
mins[j] = v[j];
if (v[j] > maxs[j])
@ -104,7 +103,7 @@ init_surf_ambients (void)
dmiptexlump_t *miptex = (dmiptexlump_t *) bsp->texdata;
for (int i = 0; i < bsp->numfaces; i++) {
for (size_t i = 0; i < bsp->numfaces; i++) {
dface_t *surf = &bsp->faces[i];
texinfo_t *info = &bsp->texinfo[surf->texinfo];
int ofs = miptex->dataofs[info->miptex];