diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 5b0affea5..6bdf57d4c 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -501,36 +501,6 @@ static void PrepareSegs() // count the segs memset(segcount, 0, numsides * sizeof(int)); - - // set up the extra data in case the map was loaded with regular nodes that might pass as GL nodes. - if (glsegextras == NULL) - { - for(int i=0;iPartnerSeg = &segs[partner]; - else seg->PartnerSeg = NULL; - seg->Subsector = glsegextras[i].Subsector; - } - } for(int i=0;i &vertexes); const int *GetOldVertexTable(); diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index bec0fbc5d..11332f049 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -53,7 +53,7 @@ #endif void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, - seg_t *&outSegs, glsegextra_t *&outSegExtras, int &segCount, + seg_t *&outSegs, int &segCount, subsector_t *&outSubs, int &subCount, TStaticArray &outVerts) { @@ -116,7 +116,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, segCount = segs.Size (); outSegs = new seg_t[segCount]; - outSegExtras = new glsegextra_t[segCount]; for (i = 0; i < segCount; ++i) { @@ -124,11 +123,11 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, if (segs[i].Partner != DWORD_MAX) { - outSegExtras[i].PartnerSeg = Segs[segs[i].Partner].storedseg; + outSegs[i].PartnerSeg = &outSegs[Segs[segs[i].Partner].storedseg]; } else { - outSegExtras[i].PartnerSeg = DWORD_MAX; + outSegs[i].PartnerSeg = nullptr; } } } @@ -137,7 +136,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, memcpy (outSubs, &Subsectors[0], subCount*sizeof(subsector_t)); segCount = Segs.Size (); outSegs = new seg_t[segCount]; - outSegExtras = NULL; for (i = 0; i < segCount; ++i) { const FPrivSeg *org = &Segs[SegList[i].SegNum]; @@ -151,6 +149,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, out->frontsector = org->frontsector; out->linedef = Level.Lines + org->linedef; out->sidedef = Level.Sides + org->sidedef; + out->PartnerSeg = nullptr; } } for (i = 0; i < subCount; ++i) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 4310c670e..35f9f4502 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -319,15 +319,13 @@ static bool LoadGLSegs(FileReader * lump) numsegs/=sizeof(glseg_t); segs = new seg_t[numsegs]; memset(segs,0,sizeof(seg_t)*numsegs); - glsegextras = new glsegextra_t[numsegs]; glseg_t * ml = (glseg_t*)data; for(i = 0; i < numsegs; i++) { // check for gl-vertices segs[i].v1 = &level.vertexes[checkGLVertex(LittleShort(ml->v1))]; segs[i].v2 = &level.vertexes[checkGLVertex(LittleShort(ml->v2))]; - - glsegextras[i].PartnerSeg = ml->partner == 0xFFFF ? DWORD_MAX : LittleShort(ml->partner); + segs[i].PartnerSeg = ml->partner == 0xFFFF ? nullptr : &segs[LittleShort(ml->partner)]; if(ml->linedef != 0xffff) { ldef = &level.lines[LittleShort(ml->linedef)]; @@ -372,15 +370,13 @@ static bool LoadGLSegs(FileReader * lump) numsegs/=sizeof(glseg3_t); segs = new seg_t[numsegs]; memset(segs,0,sizeof(seg_t)*numsegs); - glsegextras = new glsegextra_t[numsegs]; glseg3_t * ml = (glseg3_t*)(data+ (format5? 0:4)); for(i = 0; i < numsegs; i++) { // check for gl-vertices segs[i].v1 = &level.vertexes[checkGLVertex3(LittleLong(ml->v1))]; segs[i].v2 = &level.vertexes[checkGLVertex3(LittleLong(ml->v2))]; - - glsegextras[i].PartnerSeg = LittleLong(ml->partner); + segs[i].PartnerSeg = LittleLong(ml->partner) == 0xffffffffu? nullptr : &segs[LittleLong(ml->partner)]; if(ml->linedef != 0xffff) // skip minisegs { @@ -1011,7 +1007,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) FNodeBuilder builder (leveldata, polyspots, anchors, true); builder.Extract (nodes, numnodes, - segs, glsegextras, numsegs, + segs, numsegs, subsectors, numsubsectors, level.vertexes); endTime = I_FPSTime (); @@ -1112,8 +1108,7 @@ static void CreateCachedNodes(MapData *map) for(int i=0;iIndex()); - if (glsegextras != NULL) WriteLong(ZNodes, DWORD(glsegextras[i].PartnerSeg)); - else WriteLong(ZNodes, 0); + WriteLong(ZNodes, segs[i].PartnerSeg == nullptr? 0xffffffffu : DWORD(segs[i].PartnerSeg - segs)); if (segs[i].linedef) { WriteLong(ZNodes, DWORD(segs[i].linedef->Index())); @@ -1440,40 +1435,32 @@ void P_SetRenderSector() #endif // Check for incorrect partner seg info so that the following code does not crash. - if (glsegextras == NULL) + + for (i = 0; i < numsegs; i++) { - // This can be normal nodes, mistakenly identified as GL nodes so we must fill - // in the missing pieces differently. - - for (i = 0; i < numsubsectors; i++) + auto p = segs[i].PartnerSeg; + if (p != nullptr) { - ss = &subsectors[i]; - ss->render_sector = ss->sector; - } - return; - } + int partner = (int)(p - segs); - for(i=0;i= numsegs) + { + segs[i].PartnerSeg = nullptr; + } - if (partner<0 || partner>=numsegs/*eh? || &segs[partner]!=glsegextras[i].PartnerSeg*/) - { - glsegextras[i].PartnerSeg=DWORD_MAX; + // glbsp creates such incorrect references for Strife. + if (segs[i].linedef && segs[i].PartnerSeg != nullptr && !segs[i].PartnerSeg->linedef) + { + segs[i].PartnerSeg = segs[i].PartnerSeg->PartnerSeg = nullptr; + } } - // glbsp creates such incorrect references for Strife. - if (segs[i].linedef && glsegextras[i].PartnerSeg != DWORD_MAX && !segs[glsegextras[i].PartnerSeg].linedef) + for (i = 0; i < numsegs; i++) { - glsegextras[i].PartnerSeg = glsegextras[glsegextras[i].PartnerSeg].PartnerSeg = DWORD_MAX; - } - } - - for(i=0;iPartnerSeg != &segs[i]) + { + segs[i].PartnerSeg = nullptr; + } } } @@ -1501,7 +1488,7 @@ void P_SetRenderSector() seg = ss->firstline; for(j=0; jnumlines; j++) { - if(seg->sidedef && (glsegextras[seg - segs].PartnerSeg == DWORD_MAX || seg->sidedef->sector!=segs[glsegextras[seg - segs].PartnerSeg].sidedef->sector)) + if(seg->sidedef && (seg->PartnerSeg == nullptr || seg->sidedef->sector!=seg->PartnerSeg->sidedef->sector)) { ss->render_sector = seg->sidedef->sector; break; @@ -1525,15 +1512,14 @@ void P_SetRenderSector() for(j=0; jnumlines; j++) { - DWORD partner = glsegextras[seg - segs].PartnerSeg; - if (partner != DWORD_MAX && glsegextras[partner].Subsector) + if (seg->PartnerSeg != nullptr && seg->PartnerSeg->Subsector) { - sector_t * backsec = glsegextras[partner].Subsector->render_sector; + sector_t * backsec = seg->PartnerSeg->Subsector->render_sector; if (backsec) { - ss->render_sector=backsec; + ss->render_sector = backsec; undetermined.Delete(i); - deleted=1; + deleted = 1; break; } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index cf86a452d..e843cc655 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -127,7 +127,6 @@ vertexdata_t* vertexdatas; int numsegs; seg_t* segs; -glsegextra_t* glsegextras; int numsubsectors; subsector_t* subsectors; @@ -933,7 +932,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type) { seg[-1].v2 = seg->v1; } - glsegextras[seg - segs].PartnerSeg = partner; + seg->PartnerSeg = &segs[partner]; if (line != 0xFFFFFFFF) { line_t *ldef; @@ -1041,7 +1040,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes) numsegs = numSegs; segs = new seg_t[numsegs]; memset (segs, 0, numsegs*sizeof(seg_t)); - glsegextras = NULL; for (i = 0; i < numSubs; ++i) { @@ -1054,7 +1052,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } else { - glsegextras = new glsegextra_t[numsegs]; P_LoadGLZSegs (data, glnodes); } @@ -3092,14 +3089,11 @@ static void P_GroupLines (bool buildmap) { subsectors[i].sector = subsectors[i].firstline->sidedef->sector; } - if (glsegextras != NULL) + for (int i = 0; i < numsubsectors; i++) { - for (int i = 0; i < numsubsectors; i++) + for (jj = 0; jj < subsectors[i].numlines; ++jj) { - for (jj = 0; jj < subsectors[i].numlines; ++jj) - { - glsegextras[subsectors[i].firstline - segs + jj].Subsector = &subsectors[i]; - } + subsectors[i].firstline[jj].Subsector = &subsectors[i]; } } times[0].Unclock(); @@ -3437,11 +3431,6 @@ void P_FreeLevelData () segs = NULL; } numsegs = 0; - if (glsegextras != NULL) - { - delete[] glsegextras; - glsegextras = NULL; - } if (level.sectors.Size() > 0) { delete[] level.sectors[0].e; @@ -3908,7 +3897,7 @@ void P_SetupLevel (const char *lumpname, int position) // if the different machines' am_textured setting differs. FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes); builder.Extract (nodes, numnodes, - segs, glsegextras, numsegs, + segs, numsegs, subsectors, numsubsectors, level.vertexes); endTime = I_FPSTime (); @@ -4165,12 +4154,6 @@ void P_SetupLevel (const char *lumpname, int position) MapThingsUserData.Clear(); P_BackupMapData(); - - if (glsegextras != NULL) - { - delete[] glsegextras; - glsegextras = NULL; - } } diff --git a/src/p_setup.h b/src/p_setup.h index 38d61c1eb..3d8c021a7 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -150,7 +150,6 @@ struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init }; extern sidei_t *sidetemp; extern bool hasglnodes; -extern struct glsegextra_t *glsegextras; struct FMissingCount { diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 9ee543c8a..74b9fe165 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -117,6 +117,7 @@ public: sightend = t2->PosRelative(task->portalgroup); sightstart.Z += t1->Height * 0.75; + portalgroup = task->portalgroup; Startfrac = task->Frac; Trace = { sightstart.X, sightstart.Y, sightend.X - sightstart.X, sightend.Y - sightstart.Y }; Lastztop = Lastzbottom = sightstart.Z; diff --git a/src/r_defs.h b/src/r_defs.h index 6972eab65..86eb7c8c6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1418,12 +1418,6 @@ struct seg_t float sidefrac; // relative position of seg's ending vertex on owning sidedef }; -struct glsegextra_t -{ - DWORD PartnerSeg; - subsector_t *Subsector; -}; - extern seg_t *segs;