From e5f7ae07c6cf6f8ab0dcd223b1dae2a133907333 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 23 Apr 2020 23:25:51 +0200 Subject: [PATCH] Fix endianess for import of extended nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Michael Bäuerle! --- Source/p_extnodes.c | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Source/p_extnodes.c b/Source/p_extnodes.c index 8e98f20cb..4e5dd755e 100644 --- a/Source/p_extnodes.c +++ b/Source/p_extnodes.c @@ -152,10 +152,15 @@ void P_LoadSegs_DeePBSP (int lump) int side, linedef; line_t *ldef; + int vn1, vn2; + + // [MB] 2020-04-22: Fix endianess for DeePBSDP V4 nodes + vn1 = LONG(ml->v1); + vn2 = LONG(ml->v2); // [FG] extended nodes - li->v1 = &vertexes[ml->v1]; - li->v2 = &vertexes[ml->v2]; + li->v1 = &vertexes[vn1]; + li->v2 = &vertexes[vn2]; li->angle = (SHORT(ml->angle))<<16; li->offset = (SHORT(ml->offset))<<16; @@ -189,8 +194,9 @@ void P_LoadSubsectors_DeePBSP (int lump) for (i=0; ichildren[j] = (unsigned int)(mn->children[j]); + // [MB] 2020-04-22: Fix endianess for DeePBSDP V4 nodes + no->children[j] = LONG(mn->children[j]); for (k=0 ; k<4 ; k++) no->bbox[j][k] = SHORT(mn->bbox[j][k])<numsegs; - currSeg += mseg->numsegs; + subsectors[i].numlines = LONG(mseg->numsegs); + currSeg += LONG(mseg->numsegs); } data += numsubsectors * sizeof(mapsubsector_zdbsp_t); // 3. Load segs - numSegs = *((unsigned int*)data); + numSegs = LONG(*((unsigned int*)data)); data += sizeof(numSegs); // The number of stored segs should match the number of segs used by subsectors @@ -396,9 +405,12 @@ void P_LoadNodes_ZDBSP (int lump, boolean compressed) unsigned char side; seg_t *li = segs + i; mapseg_zdbsp_t *ml = (mapseg_zdbsp_t *) data + i; + unsigned int v1, v2; - li->v1 = &vertexes[ml->v1]; - li->v2 = &vertexes[ml->v2]; + v1 = LONG(ml->v1); + v2 = LONG(ml->v2); + li->v1 = &vertexes[v1]; + li->v2 = &vertexes[v2]; linedef = (unsigned short)SHORT(ml->linedef); ldef = &lines[linedef]; @@ -430,7 +442,7 @@ void P_LoadNodes_ZDBSP (int lump, boolean compressed) // 4. Load nodes - numNodes = *((unsigned int*)data); + numNodes = LONG(*((unsigned int*)data)); data += sizeof(numNodes); numnodes = numNodes; @@ -449,7 +461,7 @@ void P_LoadNodes_ZDBSP (int lump, boolean compressed) for (j = 0; j < 2; j++) { - no->children[j] = (unsigned int)(mn->children[j]); + no->children[j] = LONG(mn->children[j]); for (k = 0; k < 4; k++) no->bbox[j][k] = SHORT(mn->bbox[j][k])<