diff --git a/src/client/refresh/files/maps.c b/src/client/refresh/files/maps.c index 884b8118..e5111a69 100644 --- a/src/client/refresh/files/maps.c +++ b/src/client/refresh/files/maps.c @@ -111,7 +111,7 @@ Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs out->minmaxs[3 + j] = in->maxs[j]; } - planenum = LittleLong(in->planenum); + planenum = LittleLong(in->planenum) & 0xFFFFFFFF; if (planenum < 0 || planenum >= numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d < %d planenum.", @@ -972,7 +972,7 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t for (int surfnum = 0; surfnum < face_count; surfnum++, face_in++) { - int numverts = face_in->numedges; + unsigned int numverts = face_in->numedges; int ti = face_in->texinfo; int texFlags = texinfo_in[ti].flags; if ((ti < 0) || (ti >= texinfo_count)) diff --git a/src/client/refresh/gl1/gl1_model.c b/src/client/refresh/gl1/gl1_model.c index b276392a..f7bc1a34 100644 --- a/src/client/refresh/gl1/gl1_model.c +++ b/src/client/refresh/gl1/gl1_model.c @@ -213,7 +213,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, for (surfnum = 0; surfnum < count; surfnum++, in++, out++) { - int side, ti, planenum, lightofs; + unsigned int planenum; + int ti, side, lightofs; out->firstedge = in->firstedge; out->numedges = in->numedges; @@ -234,14 +235,14 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, out->flags |= SURF_PLANEBACK; } - if (planenum < 0 || planenum >= loadmodel->numplanes) + if (planenum >= loadmodel->numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d planenum.", __func__, planenum); } out->plane = loadmodel->planes + planenum; - ti = LittleLong(in->texinfo); + ti = in->texinfo; if ((ti < 0) || (ti >= loadmodel->numtexinfo)) { diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index f54bf4f7..eb6b2560 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -214,7 +214,8 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l, for (surfnum = 0; surfnum < count; surfnum++, in++, out++) { - int side, ti, planenum, lightofs; + unsigned int planenum; + int ti, side, lightofs; out->firstedge = in->firstedge; out->numedges = in->numedges; @@ -235,14 +236,14 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l, out->flags |= SURF_PLANEBACK; } - if (planenum < 0 || planenum >= loadmodel->numplanes) + if (planenum >= loadmodel->numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d planenum.", __func__, planenum); } out->plane = loadmodel->planes + planenum; - ti = LittleLong(in->texinfo); + ti = in->texinfo; if ((ti < 0) || (ti >= loadmodel->numtexinfo)) { diff --git a/src/client/refresh/gl4/gl4_model.c b/src/client/refresh/gl4/gl4_model.c index 36822371..5e06517a 100644 --- a/src/client/refresh/gl4/gl4_model.c +++ b/src/client/refresh/gl4/gl4_model.c @@ -214,7 +214,8 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l, for (surfnum = 0; surfnum < count; surfnum++, in++, out++) { - int side, ti, planenum, lightofs; + unsigned int planenum; + int ti, side, lightofs; out->firstedge = in->firstedge; out->numedges = in->numedges; @@ -235,14 +236,14 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l, out->flags |= SURF_PLANEBACK; } - if (planenum < 0 || planenum >= loadmodel->numplanes) + if (planenum >= loadmodel->numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d planenum.", __func__, planenum); } out->plane = loadmodel->planes + planenum; - ti = LittleLong(in->texinfo); + ti = in->texinfo; if ((ti < 0) || (ti >= loadmodel->numtexinfo)) { diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index da25711b..8ce47c82 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -207,7 +207,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, for (surfnum = 0; surfnum < count; surfnum++, in++, out++) { - int side, ti, planenum, lightofs; + unsigned int planenum; + int ti, side, lightofs; out->firstedge = in->firstedge; out->numedges = in->numedges; @@ -228,14 +229,14 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, out->flags |= SURF_PLANEBACK; } - if (planenum < 0 || planenum >= loadmodel->numplanes) + if (planenum >= loadmodel->numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d planenum.", __func__, planenum); } out->plane = loadmodel->planes + planenum; - ti = LittleLong(in->texinfo); + ti = in->texinfo; if ((ti < 0) || (ti >= loadmodel->numtexinfo)) { diff --git a/src/client/refresh/vk/vk_model.c b/src/client/refresh/vk/vk_model.c index 3b34d309..e3f41acd 100644 --- a/src/client/refresh/vk/vk_model.c +++ b/src/client/refresh/vk/vk_model.c @@ -188,7 +188,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, for (surfnum = 0; surfnum < count; surfnum++, in++, out++) { - int side, ti, planenum, lightofs; + unsigned int planenum; + int ti, side, lightofs; out->firstedge = in->firstedge; out->numedges = in->numedges; @@ -209,14 +210,14 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, out->flags |= SURF_PLANEBACK; } - if (planenum < 0 || planenum >= loadmodel->numplanes) + if (planenum >= loadmodel->numplanes) { Com_Error(ERR_DROP, "%s: Incorrect %d planenum.", __func__, planenum); } out->plane = loadmodel->planes + planenum; - ti = LittleLong(in->texinfo); + ti = in->texinfo; if ((ti < 0) || (ti >= loadmodel->numtexinfo)) { diff --git a/src/common/header/files.h b/src/common/header/files.h index 1fac939b..19f27efc 100644 --- a/src/common/header/files.h +++ b/src/common/header/files.h @@ -784,7 +784,7 @@ typedef struct typedef struct { - int planenum; + unsigned int planenum; int children[2]; /* negative numbers are -(leafs+1), not nodes */ short mins[3]; /* for frustom culling */ short maxs[3]; @@ -794,7 +794,7 @@ typedef struct typedef struct { - int planenum; + unsigned int planenum; int children[2]; /* negative numbers are -(leafs+1), not nodes */ float mins[3]; /* for frustom culling */ float maxs[3]; @@ -838,10 +838,10 @@ typedef struct typedef struct { unsigned short planenum; - short side; + unsigned short side; - int firstedge; /* we must support > 64k edges */ - short numedges; + unsigned int firstedge; /* we must support > 64k edges */ + unsigned short numedges; short texinfo; /* lighting info */ @@ -852,10 +852,10 @@ typedef struct typedef struct { unsigned int planenum; - int side; + unsigned int side; - int firstedge; /* we must support > 64k edges */ - int numedges; + unsigned int firstedge; /* we must support > 64k edges */ + unsigned int numedges; int texinfo; /* lighting info */ @@ -994,10 +994,10 @@ typedef struct texsininfo_s typedef struct { unsigned short planenum; - short side; + unsigned short side; - int firstedge; /* we must support > 64k edges */ - short numedges; + unsigned int firstedge; /* we must support > 64k edges */ + unsigned short numedges; short texinfo; /* lighting info */ diff --git a/src/common/maps.c b/src/common/maps.c index f7527d77..125b7678 100644 --- a/src/common/maps.c +++ b/src/common/maps.c @@ -205,7 +205,7 @@ Mod_Load2QBSP_IBSP_NODES(byte *outbuf, dheader_t *outheader, out->maxs[j] = LittleShort(in->maxs[j]); } - out->planenum = LittleLong(in->planenum); + out->planenum = LittleLong(in->planenum) & 0xFFFFFFFF; out->firstface = LittleShort(in->firstface) & 0xFFFF; out->numfaces = LittleShort(in->numfaces) & 0xFFFF; @@ -241,7 +241,7 @@ Mod_Load2QBSP_QBSP_NODES(byte *outbuf, dheader_t *outheader, out->maxs[j] = LittleFloat(in->maxs[j]); } - out->planenum = LittleLong(in->planenum); + out->planenum = LittleLong(in->planenum) & 0xFFFFFFFF; out->firstface = LittleLong(in->firstface) & 0xFFFFFFFF; out->numfaces = LittleLong(in->numfaces) & 0xFFFFFFFF; @@ -336,10 +336,10 @@ Mod_Load2QBSP_IBSP_FACES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleShort(in->planenum); - out->side = LittleShort(in->side); - out->firstedge = LittleLong(in->firstedge); - out->numedges = LittleShort(in->numedges); + out->planenum = LittleShort(in->planenum) & 0xFFFF; + out->side = LittleShort(in->side) & 0xFFFF; + out->firstedge = LittleLong(in->firstedge) & 0xFFFFFFFF; + out->numedges = LittleShort(in->numedges) & 0xFFFF; out->texinfo = LittleShort(in->texinfo); memcpy(out->styles, in->styles, Q_min(sizeof(out->styles), sizeof(in->styles))); out->lightofs = LittleLong(in->lightofs); @@ -364,10 +364,10 @@ Mod_Load2QBSP_RBSP_FACES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleShort(in->planenum); - out->side = LittleShort(in->side); - out->firstedge = LittleLong(in->firstedge); - out->numedges = LittleShort(in->numedges); + out->planenum = LittleShort(in->planenum) & 0xFFFF; + out->side = LittleShort(in->side) & 0xFFFF; + out->firstedge = LittleLong(in->firstedge) & 0xFFFFFFFF; + out->numedges = LittleShort(in->numedges) & 0xFFFF; out->texinfo = LittleShort(in->texinfo); memcpy(out->styles, in->styles, Q_min(sizeof(out->styles), sizeof(in->styles))); out->lightofs = LittleLong(in->lightofs); @@ -392,10 +392,10 @@ Mod_Load2QBSP_QBSP_FACES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleLong(in->planenum); - out->side = LittleLong(in->side); - out->firstedge = LittleLong(in->firstedge); - out->numedges = LittleLong(in->numedges); + out->planenum = LittleLong(in->planenum) & 0xFFFFFFFF; + out->side = LittleLong(in->side) & 0xFFFFFFFF; + out->firstedge = LittleLong(in->firstedge) & 0xFFFFFFFF; + out->numedges = LittleLong(in->numedges) & 0xFFFFFFFF; out->texinfo = LittleLong(in->texinfo); memcpy(out->styles, in->styles, Q_min(sizeof(out->styles), sizeof(in->styles))); out->lightofs = LittleLong(in->lightofs); @@ -699,7 +699,7 @@ Mod_Load2QBSP_IBSP_BRUSHSIDES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleShort(in->planenum); + out->planenum = LittleShort(in->planenum) & 0xFFFF; out->texinfo = LittleShort(in->texinfo); out++; @@ -722,7 +722,7 @@ Mod_Load2QBSP_RBSP_BRUSHSIDES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleShort(in->planenum); + out->planenum = LittleShort(in->planenum) & 0xFFFF; out->texinfo = LittleShort(in->texinfo); out++; @@ -744,7 +744,7 @@ Mod_Load2QBSP_QBSP_BRUSHSIDES(byte *outbuf, dheader_t *outheader, for (i = 0; i < count; i++) { - out->planenum = LittleLong(in->planenum); + out->planenum = LittleLong(in->planenum) & 0xFFFFFFFF; out->texinfo = LittleLong(in->texinfo); out++;