mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-31 05:40:44 +00:00
- fixed: The sight checker's portalgroup variable was not initialized.
- got rid of glsegextras. This was probably one of the most ill-conceived means to save some memory in ZDoom, but now, when a pure software rendered engine no longer needs to be considered it's just totally useless to keep this mess in.
This commit is contained in:
parent
12037fdc95
commit
b9ac44e8f2
8 changed files with 39 additions and 107 deletions
|
@ -501,36 +501,6 @@ static void PrepareSegs()
|
||||||
|
|
||||||
// count the segs
|
// count the segs
|
||||||
memset(segcount, 0, numsides * sizeof(int));
|
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;i<numsegs;i++)
|
|
||||||
{
|
|
||||||
segs[i].PartnerSeg = NULL;
|
|
||||||
}
|
|
||||||
for (int i=0; i<numsubsectors; i++)
|
|
||||||
{
|
|
||||||
int seg = int(subsectors[i].firstline-segs);
|
|
||||||
for(DWORD j=0;j<subsectors[i].numlines;j++)
|
|
||||||
{
|
|
||||||
segs[j+seg].Subsector = &subsectors[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int i=0;i<numsegs;i++)
|
|
||||||
{
|
|
||||||
seg_t *seg = &segs[i];
|
|
||||||
|
|
||||||
// Account for ZDoom space optimizations that cannot be done for GL
|
|
||||||
unsigned int partner= glsegextras[i].PartnerSeg;
|
|
||||||
if (partner < unsigned(numsegs)) seg->PartnerSeg = &segs[partner];
|
|
||||||
else seg->PartnerSeg = NULL;
|
|
||||||
seg->Subsector = glsegextras[i].Subsector;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0;i<numsegs;i++)
|
for(int i=0;i<numsegs;i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ public:
|
||||||
~FNodeBuilder ();
|
~FNodeBuilder ();
|
||||||
|
|
||||||
void Extract(node_t *&nodes, int &nodeCount,
|
void Extract(node_t *&nodes, int &nodeCount,
|
||||||
seg_t *&segs, glsegextra_t *&glsegextras, int &segCount,
|
seg_t *&segs, int &segCount,
|
||||||
subsector_t *&ssecs, int &subCount,
|
subsector_t *&ssecs, int &subCount,
|
||||||
TStaticArray<vertex_t> &vertexes);
|
TStaticArray<vertex_t> &vertexes);
|
||||||
const int *GetOldVertexTable();
|
const int *GetOldVertexTable();
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
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,
|
subsector_t *&outSubs, int &subCount,
|
||||||
TStaticArray<vertex_t> &outVerts)
|
TStaticArray<vertex_t> &outVerts)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
|
|
||||||
segCount = segs.Size ();
|
segCount = segs.Size ();
|
||||||
outSegs = new seg_t[segCount];
|
outSegs = new seg_t[segCount];
|
||||||
outSegExtras = new glsegextra_t[segCount];
|
|
||||||
|
|
||||||
for (i = 0; i < segCount; ++i)
|
for (i = 0; i < segCount; ++i)
|
||||||
{
|
{
|
||||||
|
@ -124,11 +123,11 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
|
|
||||||
if (segs[i].Partner != DWORD_MAX)
|
if (segs[i].Partner != DWORD_MAX)
|
||||||
{
|
{
|
||||||
outSegExtras[i].PartnerSeg = Segs[segs[i].Partner].storedseg;
|
outSegs[i].PartnerSeg = &outSegs[Segs[segs[i].Partner].storedseg];
|
||||||
}
|
}
|
||||||
else
|
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));
|
memcpy (outSubs, &Subsectors[0], subCount*sizeof(subsector_t));
|
||||||
segCount = Segs.Size ();
|
segCount = Segs.Size ();
|
||||||
outSegs = new seg_t[segCount];
|
outSegs = new seg_t[segCount];
|
||||||
outSegExtras = NULL;
|
|
||||||
for (i = 0; i < segCount; ++i)
|
for (i = 0; i < segCount; ++i)
|
||||||
{
|
{
|
||||||
const FPrivSeg *org = &Segs[SegList[i].SegNum];
|
const FPrivSeg *org = &Segs[SegList[i].SegNum];
|
||||||
|
@ -151,6 +149,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
out->frontsector = org->frontsector;
|
out->frontsector = org->frontsector;
|
||||||
out->linedef = Level.Lines + org->linedef;
|
out->linedef = Level.Lines + org->linedef;
|
||||||
out->sidedef = Level.Sides + org->sidedef;
|
out->sidedef = Level.Sides + org->sidedef;
|
||||||
|
out->PartnerSeg = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < subCount; ++i)
|
for (i = 0; i < subCount; ++i)
|
||||||
|
|
|
@ -319,15 +319,13 @@ static bool LoadGLSegs(FileReader * lump)
|
||||||
numsegs/=sizeof(glseg_t);
|
numsegs/=sizeof(glseg_t);
|
||||||
segs = new seg_t[numsegs];
|
segs = new seg_t[numsegs];
|
||||||
memset(segs,0,sizeof(seg_t)*numsegs);
|
memset(segs,0,sizeof(seg_t)*numsegs);
|
||||||
glsegextras = new glsegextra_t[numsegs];
|
|
||||||
|
|
||||||
glseg_t * ml = (glseg_t*)data;
|
glseg_t * ml = (glseg_t*)data;
|
||||||
for(i = 0; i < numsegs; i++)
|
for(i = 0; i < numsegs; i++)
|
||||||
{ // check for gl-vertices
|
{ // check for gl-vertices
|
||||||
segs[i].v1 = &level.vertexes[checkGLVertex(LittleShort(ml->v1))];
|
segs[i].v1 = &level.vertexes[checkGLVertex(LittleShort(ml->v1))];
|
||||||
segs[i].v2 = &level.vertexes[checkGLVertex(LittleShort(ml->v2))];
|
segs[i].v2 = &level.vertexes[checkGLVertex(LittleShort(ml->v2))];
|
||||||
|
segs[i].PartnerSeg = ml->partner == 0xFFFF ? nullptr : &segs[LittleShort(ml->partner)];
|
||||||
glsegextras[i].PartnerSeg = ml->partner == 0xFFFF ? DWORD_MAX : LittleShort(ml->partner);
|
|
||||||
if(ml->linedef != 0xffff)
|
if(ml->linedef != 0xffff)
|
||||||
{
|
{
|
||||||
ldef = &level.lines[LittleShort(ml->linedef)];
|
ldef = &level.lines[LittleShort(ml->linedef)];
|
||||||
|
@ -372,15 +370,13 @@ static bool LoadGLSegs(FileReader * lump)
|
||||||
numsegs/=sizeof(glseg3_t);
|
numsegs/=sizeof(glseg3_t);
|
||||||
segs = new seg_t[numsegs];
|
segs = new seg_t[numsegs];
|
||||||
memset(segs,0,sizeof(seg_t)*numsegs);
|
memset(segs,0,sizeof(seg_t)*numsegs);
|
||||||
glsegextras = new glsegextra_t[numsegs];
|
|
||||||
|
|
||||||
glseg3_t * ml = (glseg3_t*)(data+ (format5? 0:4));
|
glseg3_t * ml = (glseg3_t*)(data+ (format5? 0:4));
|
||||||
for(i = 0; i < numsegs; i++)
|
for(i = 0; i < numsegs; i++)
|
||||||
{ // check for gl-vertices
|
{ // check for gl-vertices
|
||||||
segs[i].v1 = &level.vertexes[checkGLVertex3(LittleLong(ml->v1))];
|
segs[i].v1 = &level.vertexes[checkGLVertex3(LittleLong(ml->v1))];
|
||||||
segs[i].v2 = &level.vertexes[checkGLVertex3(LittleLong(ml->v2))];
|
segs[i].v2 = &level.vertexes[checkGLVertex3(LittleLong(ml->v2))];
|
||||||
|
segs[i].PartnerSeg = LittleLong(ml->partner) == 0xffffffffu? nullptr : &segs[LittleLong(ml->partner)];
|
||||||
glsegextras[i].PartnerSeg = LittleLong(ml->partner);
|
|
||||||
|
|
||||||
if(ml->linedef != 0xffff) // skip minisegs
|
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);
|
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
||||||
|
|
||||||
builder.Extract (nodes, numnodes,
|
builder.Extract (nodes, numnodes,
|
||||||
segs, glsegextras, numsegs,
|
segs, numsegs,
|
||||||
subsectors, numsubsectors,
|
subsectors, numsubsectors,
|
||||||
level.vertexes);
|
level.vertexes);
|
||||||
endTime = I_FPSTime ();
|
endTime = I_FPSTime ();
|
||||||
|
@ -1112,8 +1108,7 @@ static void CreateCachedNodes(MapData *map)
|
||||||
for(int i=0;i<numsegs;i++)
|
for(int i=0;i<numsegs;i++)
|
||||||
{
|
{
|
||||||
WriteLong(ZNodes, segs[i].v1->Index());
|
WriteLong(ZNodes, segs[i].v1->Index());
|
||||||
if (glsegextras != NULL) WriteLong(ZNodes, DWORD(glsegextras[i].PartnerSeg));
|
WriteLong(ZNodes, segs[i].PartnerSeg == nullptr? 0xffffffffu : DWORD(segs[i].PartnerSeg - segs));
|
||||||
else WriteLong(ZNodes, 0);
|
|
||||||
if (segs[i].linedef)
|
if (segs[i].linedef)
|
||||||
{
|
{
|
||||||
WriteLong(ZNodes, DWORD(segs[i].linedef->Index()));
|
WriteLong(ZNodes, DWORD(segs[i].linedef->Index()));
|
||||||
|
@ -1440,40 +1435,32 @@ void P_SetRenderSector()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for incorrect partner seg info so that the following code does not crash.
|
// 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
|
auto p = segs[i].PartnerSeg;
|
||||||
// in the missing pieces differently.
|
if (p != nullptr)
|
||||||
|
|
||||||
for (i = 0; i < numsubsectors; i++)
|
|
||||||
{
|
{
|
||||||
ss = &subsectors[i];
|
int partner = (int)(p - segs);
|
||||||
ss->render_sector = ss->sector;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0;i<numsegs;i++)
|
if (partner < 0 || partner >= numsegs)
|
||||||
{
|
{
|
||||||
int partner = (int)glsegextras[i].PartnerSeg;
|
segs[i].PartnerSeg = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (partner<0 || partner>=numsegs/*eh? || &segs[partner]!=glsegextras[i].PartnerSeg*/)
|
// glbsp creates such incorrect references for Strife.
|
||||||
{
|
if (segs[i].linedef && segs[i].PartnerSeg != nullptr && !segs[i].PartnerSeg->linedef)
|
||||||
glsegextras[i].PartnerSeg=DWORD_MAX;
|
{
|
||||||
|
segs[i].PartnerSeg = segs[i].PartnerSeg->PartnerSeg = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// glbsp creates such incorrect references for Strife.
|
for (i = 0; i < numsegs; i++)
|
||||||
if (segs[i].linedef && glsegextras[i].PartnerSeg != DWORD_MAX && !segs[glsegextras[i].PartnerSeg].linedef)
|
|
||||||
{
|
{
|
||||||
glsegextras[i].PartnerSeg = glsegextras[glsegextras[i].PartnerSeg].PartnerSeg = DWORD_MAX;
|
if (segs[i].PartnerSeg != nullptr && segs[i].PartnerSeg->PartnerSeg != &segs[i])
|
||||||
}
|
{
|
||||||
}
|
segs[i].PartnerSeg = nullptr;
|
||||||
|
}
|
||||||
for(i=0;i<numsegs;i++)
|
|
||||||
{
|
|
||||||
if (glsegextras[i].PartnerSeg != DWORD_MAX && glsegextras[glsegextras[i].PartnerSeg].PartnerSeg!=(DWORD)i)
|
|
||||||
{
|
|
||||||
glsegextras[i].PartnerSeg=DWORD_MAX;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,7 +1488,7 @@ void P_SetRenderSector()
|
||||||
seg = ss->firstline;
|
seg = ss->firstline;
|
||||||
for(j=0; j<ss->numlines; j++)
|
for(j=0; j<ss->numlines; 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;
|
ss->render_sector = seg->sidedef->sector;
|
||||||
break;
|
break;
|
||||||
|
@ -1525,15 +1512,14 @@ void P_SetRenderSector()
|
||||||
|
|
||||||
for(j=0; j<ss->numlines; j++)
|
for(j=0; j<ss->numlines; j++)
|
||||||
{
|
{
|
||||||
DWORD partner = glsegextras[seg - segs].PartnerSeg;
|
if (seg->PartnerSeg != nullptr && seg->PartnerSeg->Subsector)
|
||||||
if (partner != DWORD_MAX && glsegextras[partner].Subsector)
|
|
||||||
{
|
{
|
||||||
sector_t * backsec = glsegextras[partner].Subsector->render_sector;
|
sector_t * backsec = seg->PartnerSeg->Subsector->render_sector;
|
||||||
if (backsec)
|
if (backsec)
|
||||||
{
|
{
|
||||||
ss->render_sector=backsec;
|
ss->render_sector = backsec;
|
||||||
undetermined.Delete(i);
|
undetermined.Delete(i);
|
||||||
deleted=1;
|
deleted = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ vertexdata_t* vertexdatas;
|
||||||
|
|
||||||
int numsegs;
|
int numsegs;
|
||||||
seg_t* segs;
|
seg_t* segs;
|
||||||
glsegextra_t* glsegextras;
|
|
||||||
|
|
||||||
int numsubsectors;
|
int numsubsectors;
|
||||||
subsector_t* subsectors;
|
subsector_t* subsectors;
|
||||||
|
@ -933,7 +932,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type)
|
||||||
{
|
{
|
||||||
seg[-1].v2 = seg->v1;
|
seg[-1].v2 = seg->v1;
|
||||||
}
|
}
|
||||||
glsegextras[seg - segs].PartnerSeg = partner;
|
seg->PartnerSeg = &segs[partner];
|
||||||
if (line != 0xFFFFFFFF)
|
if (line != 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
line_t *ldef;
|
line_t *ldef;
|
||||||
|
@ -1041,7 +1040,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
||||||
numsegs = numSegs;
|
numsegs = numSegs;
|
||||||
segs = new seg_t[numsegs];
|
segs = new seg_t[numsegs];
|
||||||
memset (segs, 0, numsegs*sizeof(seg_t));
|
memset (segs, 0, numsegs*sizeof(seg_t));
|
||||||
glsegextras = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < numSubs; ++i)
|
for (i = 0; i < numSubs; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1054,7 +1052,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glsegextras = new glsegextra_t[numsegs];
|
|
||||||
P_LoadGLZSegs (data, glnodes);
|
P_LoadGLZSegs (data, glnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3092,14 +3089,11 @@ static void P_GroupLines (bool buildmap)
|
||||||
{
|
{
|
||||||
subsectors[i].sector = subsectors[i].firstline->sidedef->sector;
|
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)
|
subsectors[i].firstline[jj].Subsector = &subsectors[i];
|
||||||
{
|
|
||||||
glsegextras[subsectors[i].firstline - segs + jj].Subsector = &subsectors[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
times[0].Unclock();
|
times[0].Unclock();
|
||||||
|
@ -3437,11 +3431,6 @@ void P_FreeLevelData ()
|
||||||
segs = NULL;
|
segs = NULL;
|
||||||
}
|
}
|
||||||
numsegs = 0;
|
numsegs = 0;
|
||||||
if (glsegextras != NULL)
|
|
||||||
{
|
|
||||||
delete[] glsegextras;
|
|
||||||
glsegextras = NULL;
|
|
||||||
}
|
|
||||||
if (level.sectors.Size() > 0)
|
if (level.sectors.Size() > 0)
|
||||||
{
|
{
|
||||||
delete[] level.sectors[0].e;
|
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.
|
// if the different machines' am_textured setting differs.
|
||||||
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
||||||
builder.Extract (nodes, numnodes,
|
builder.Extract (nodes, numnodes,
|
||||||
segs, glsegextras, numsegs,
|
segs, numsegs,
|
||||||
subsectors, numsubsectors,
|
subsectors, numsubsectors,
|
||||||
level.vertexes);
|
level.vertexes);
|
||||||
endTime = I_FPSTime ();
|
endTime = I_FPSTime ();
|
||||||
|
@ -4165,12 +4154,6 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
MapThingsUserData.Clear();
|
MapThingsUserData.Clear();
|
||||||
|
|
||||||
P_BackupMapData();
|
P_BackupMapData();
|
||||||
|
|
||||||
if (glsegextras != NULL)
|
|
||||||
{
|
|
||||||
delete[] glsegextras;
|
|
||||||
glsegextras = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,6 @@ struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init
|
||||||
};
|
};
|
||||||
extern sidei_t *sidetemp;
|
extern sidei_t *sidetemp;
|
||||||
extern bool hasglnodes;
|
extern bool hasglnodes;
|
||||||
extern struct glsegextra_t *glsegextras;
|
|
||||||
|
|
||||||
struct FMissingCount
|
struct FMissingCount
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,6 +117,7 @@ public:
|
||||||
sightend = t2->PosRelative(task->portalgroup);
|
sightend = t2->PosRelative(task->portalgroup);
|
||||||
sightstart.Z += t1->Height * 0.75;
|
sightstart.Z += t1->Height * 0.75;
|
||||||
|
|
||||||
|
portalgroup = task->portalgroup;
|
||||||
Startfrac = task->Frac;
|
Startfrac = task->Frac;
|
||||||
Trace = { sightstart.X, sightstart.Y, sightend.X - sightstart.X, sightend.Y - sightstart.Y };
|
Trace = { sightstart.X, sightstart.Y, sightend.X - sightstart.X, sightend.Y - sightstart.Y };
|
||||||
Lastztop = Lastzbottom = sightstart.Z;
|
Lastztop = Lastzbottom = sightstart.Z;
|
||||||
|
|
|
@ -1418,12 +1418,6 @@ struct seg_t
|
||||||
float sidefrac; // relative position of seg's ending vertex on owning sidedef
|
float sidefrac; // relative position of seg's ending vertex on owning sidedef
|
||||||
};
|
};
|
||||||
|
|
||||||
struct glsegextra_t
|
|
||||||
{
|
|
||||||
DWORD PartnerSeg;
|
|
||||||
subsector_t *Subsector;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern seg_t *segs;
|
extern seg_t *segs;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue