Change type signs of some members in doomdata.h, add USHORT/ULONG to m_swap.h for setup code to use for getting sector/sidedef/linedef/vertex/etc numbers

I did this to attempt to fix a map so large it was acting very weird; sadly I have no idea if it's purely the number of stuff in the map or whether the nodebuilder mucks everything up anyway
This commit is contained in:
Monster Iestyn 2017-06-18 22:49:06 +01:00
parent ab0445ae28
commit fc1bcb38c2
3 changed files with 22 additions and 17 deletions

View file

@ -74,14 +74,14 @@ typedef struct
INT16 textureoffset, rowoffset;
char toptexture[8], bottomtexture[8], midtexture[8];
// Front sector, towards viewer.
INT16 sector;
UINT16 sector;
} ATTRPACK mapsidedef_t;
// A LineDef, as used for editing, and as input
// to the BSP builder.
typedef struct
{
INT16 v1, v2;
UINT16 v1, v2;
INT16 flags;
INT16 special;
INT16 tag;
@ -163,9 +163,9 @@ typedef struct
// using partition lines selected by BSP builder.
typedef struct
{
INT16 v1, v2;
UINT16 v1, v2;
INT16 angle;
INT16 linedef;
UINT16 linedef;
INT16 side;
INT16 offset;
} ATTRPACK mapseg_t;

View file

@ -39,4 +39,8 @@
#define LONG(x) ((INT32)(x))
#endif
// Unsigned versions
#define USHORT(x) (UINT16)SHORT(x)
#define ULONG(x) (UINT32)LONG(x)
#endif

View file

@ -425,7 +425,8 @@ static void P_LoadSegs(lumpnum_t lumpnum)
{
UINT8 *data;
size_t i;
INT32 linedef, side;
UINT16 linedef;
INT32 side;
mapseg_t *ml;
seg_t *li;
line_t *ldef;
@ -440,8 +441,8 @@ static void P_LoadSegs(lumpnum_t lumpnum)
li = segs;
for (i = 0; i < numsegs; i++, li++, ml++)
{
li->v1 = &vertexes[SHORT(ml->v1)];
li->v2 = &vertexes[SHORT(ml->v2)];
li->v1 = &vertexes[USHORT(ml->v1)];
li->v2 = &vertexes[USHORT(ml->v2)];
#ifdef HWRENDER // not win32 only 19990829 by Kin
// used for the hardware render
@ -455,7 +456,7 @@ static void P_LoadSegs(lumpnum_t lumpnum)
li->angle = (SHORT(ml->angle))<<FRACBITS;
li->offset = (SHORT(ml->offset))<<FRACBITS;
linedef = SHORT(ml->linedef);
linedef = USHORT(ml->linedef);
ldef = &lines[linedef];
li->linedef = ldef;
li->side = side = SHORT(ml->side);
@ -496,8 +497,8 @@ static inline void P_LoadSubsectors(lumpnum_t lumpnum)
for (i = 0; i < numsubsectors; i++, ss++, ms++)
{
ss->sector = NULL;
ss->numlines = SHORT(ms->numsegs);
ss->firstline = SHORT(ms->firstseg);
ss->numlines = USHORT(ms->numsegs);
ss->firstline = USHORT(ms->firstseg);
#ifdef FLOORSPLATS
ss->splats = NULL;
#endif
@ -775,7 +776,7 @@ static void P_LoadNodes(lumpnum_t lumpnum)
no->dy = SHORT(mn->dy)<<FRACBITS;
for (j = 0; j < 2; j++)
{
no->children[j] = SHORT(mn->children[j]);
no->children[j] = USHORT(mn->children[j]);
for (k = 0; k < 4; k++)
no->bbox[j][k] = SHORT(mn->bbox[j][k])<<FRACBITS;
}
@ -1163,8 +1164,8 @@ static void P_LoadLineDefs(lumpnum_t lumpnum)
ld->flags = SHORT(mld->flags);
ld->special = SHORT(mld->special);
ld->tag = SHORT(mld->tag);
v1 = ld->v1 = &vertexes[SHORT(mld->v1)];
v2 = ld->v2 = &vertexes[SHORT(mld->v2)];
v1 = ld->v1 = &vertexes[USHORT(mld->v1)];
v2 = ld->v2 = &vertexes[USHORT(mld->v2)];
ld->dx = v2->x - v1->x;
ld->dy = v2->y - v1->y;
@ -1203,8 +1204,8 @@ static void P_LoadLineDefs(lumpnum_t lumpnum)
ld->bbox[BOXTOP] = v1->y;
}
ld->sidenum[0] = SHORT(mld->sidenum[0]);
ld->sidenum[1] = SHORT(mld->sidenum[1]);
ld->sidenum[0] = USHORT(mld->sidenum[0]);
ld->sidenum[1] = USHORT(mld->sidenum[1]);
{
// cph 2006/09/30 - fix sidedef errors right away.
@ -1381,7 +1382,7 @@ static void P_LoadSideDefs2(lumpnum_t lumpnum)
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
{ /* cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead */
UINT16 sector_num = SHORT(msd->sector);
UINT16 sector_num = USHORT(msd->sector);
if (sector_num >= numsectors)
{
@ -1394,7 +1395,7 @@ static void P_LoadSideDefs2(lumpnum_t lumpnum)
// refined to allow colormaps to work as wall textures if invalid as colormaps
// but valid as textures.
sd->sector = sec = &sectors[SHORT(msd->sector)];
sd->sector = sec = &sectors[USHORT(msd->sector)];
// Colormaps!
switch (sd->special)