game: fix load of Anachronox levant2 map

Fields planenum, side, firstedge, numedges has made unsigned.
This commit is contained in:
Denis Pauk 2024-09-22 01:05:28 +03:00
parent ecb53ba29f
commit 36011a51c4
8 changed files with 50 additions and 45 deletions

View file

@ -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))

View file

@ -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))
{

View file

@ -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))
{

View file

@ -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))
{

View file

@ -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))
{

View file

@ -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))
{

View file

@ -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 */

View file

@ -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++;