From fc1bcb38c263e0b5e8f4d384ca26f368791603d7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 18 Jun 2017 22:49:06 +0100 Subject: [PATCH] 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 --- src/doomdata.h | 8 ++++---- src/m_swap.h | 4 ++++ src/p_setup.c | 27 ++++++++++++++------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index e916a151f..8556e54cb 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -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; diff --git a/src/m_swap.h b/src/m_swap.h index 2352a0b23..c33db0c80 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -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 diff --git a/src/p_setup.c b/src/p_setup.c index 8e746457b..6eda5d705 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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))<offset = (SHORT(ml->offset))<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)<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])<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)<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 = §ors[SHORT(msd->sector)]; + sd->sector = sec = §ors[USHORT(msd->sector)]; // Colormaps! switch (sd->special)