mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- moved the content from p_glnodes into the MapLoader class.
This commit is contained in:
parent
2e22c01d45
commit
89ba723609
3 changed files with 126 additions and 116 deletions
|
@ -118,14 +118,14 @@ struct gl5_mapnode_t
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static int CheckForMissingSegs()
|
||||
int MapLoader::CheckForMissingSegs()
|
||||
{
|
||||
auto numsides = level.sides.Size();
|
||||
auto numsides = Level->sides.Size();
|
||||
double *added_seglen = new double[numsides];
|
||||
int missing = 0;
|
||||
|
||||
memset(added_seglen, 0, sizeof(double)*numsides);
|
||||
for (auto &seg : level.segs)
|
||||
for (auto &seg : Level->segs)
|
||||
{
|
||||
if (seg.sidedef != nullptr)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ static int CheckForMissingSegs()
|
|||
|
||||
for (unsigned i = 0; i < numsides; i++)
|
||||
{
|
||||
double linelen = level.sides[i].linedef->Delta().Length();
|
||||
double linelen = Level->sides[i].linedef->Delta().Length();
|
||||
missing += (added_seglen[i] < linelen - 1.);
|
||||
}
|
||||
|
||||
|
@ -151,9 +151,9 @@ static int CheckForMissingSegs()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool P_CheckForGLNodes()
|
||||
bool MapLoader::CheckForGLNodes()
|
||||
{
|
||||
for(auto &sub : level.subsectors)
|
||||
for(auto &sub : Level->subsectors)
|
||||
{
|
||||
seg_t * firstseg = sub.firstline;
|
||||
seg_t * lastseg = sub.firstline + sub.numlines - 1;
|
||||
|
@ -168,7 +168,7 @@ bool P_CheckForGLNodes()
|
|||
{
|
||||
for(uint32_t j=0;j<sub.numlines;j++)
|
||||
{
|
||||
if (level.segs[j].linedef==NULL) // miniseg
|
||||
if (Level->segs[j].linedef==nullptr) // miniseg
|
||||
{
|
||||
// We already have GL nodes. Great!
|
||||
return true;
|
||||
|
@ -201,14 +201,12 @@ bool P_CheckForGLNodes()
|
|||
#define gNd5 MAKE_ID('g','N','d','5')
|
||||
|
||||
#define GL_VERT_OFFSET 4
|
||||
static int firstglvertex;
|
||||
static bool format5;
|
||||
|
||||
static bool LoadGLVertexes(FileReader &lump)
|
||||
bool MapLoader::LoadGLVertexes(FileReader &lump)
|
||||
{
|
||||
int i;
|
||||
|
||||
firstglvertex = level.vertexes.Size();
|
||||
firstglvertex = Level->vertexes.Size();
|
||||
|
||||
lump.Seek(0, FileReader::SeekSet);
|
||||
auto glbuf = lump.Read();
|
||||
|
@ -234,19 +232,19 @@ static bool LoadGLVertexes(FileReader &lump)
|
|||
mapglvertex_t* mgl = (mapglvertex_t *)(gldata + GL_VERT_OFFSET);
|
||||
unsigned numvertexes = (unsigned)(firstglvertex + (gllen - GL_VERT_OFFSET)/sizeof(mapglvertex_t));
|
||||
|
||||
auto oldvertexes = &level.vertexes[0];
|
||||
level.vertexes.Resize(numvertexes);
|
||||
auto oldvertexes = &Level->vertexes[0];
|
||||
Level->vertexes.Resize(numvertexes);
|
||||
|
||||
for(auto &line : level.lines)
|
||||
for(auto &line : Level->lines)
|
||||
{
|
||||
// Remap vertex pointers in linedefs
|
||||
line.v1 = &level.vertexes[line.v1 - oldvertexes];
|
||||
line.v2 = &level.vertexes[line.v2 - oldvertexes];
|
||||
line.v1 = &Level->vertexes[line.v1 - oldvertexes];
|
||||
line.v2 = &Level->vertexes[line.v2 - oldvertexes];
|
||||
}
|
||||
|
||||
for (i = firstglvertex; i < (int)numvertexes; i++)
|
||||
{
|
||||
level.vertexes[i].set(LittleLong(mgl->x)/65536., LittleLong(mgl->y)/65536.);
|
||||
Level->vertexes[i].set(LittleLong(mgl->x)/65536., LittleLong(mgl->y)/65536.);
|
||||
mgl++;
|
||||
}
|
||||
return true;
|
||||
|
@ -258,14 +256,14 @@ static bool LoadGLVertexes(FileReader &lump)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static inline int checkGLVertex(int num)
|
||||
int MapLoader::checkGLVertex(int num)
|
||||
{
|
||||
if (num & 0x8000)
|
||||
num = (num&0x7FFF)+firstglvertex;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline int checkGLVertex3(int num)
|
||||
int MapLoader::checkGLVertex3(int num)
|
||||
{
|
||||
if (num & 0xc0000000)
|
||||
num = (num&0x3FFFFFFF)+firstglvertex;
|
||||
|
@ -278,63 +276,63 @@ static inline int checkGLVertex3(int num)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool LoadGLSegs(FileReader &lump)
|
||||
bool MapLoader::LoadGLSegs(FileReader &lump)
|
||||
{
|
||||
int i;
|
||||
line_t *ldef=NULL;
|
||||
line_t *ldef=nullptr;
|
||||
|
||||
lump.Seek(0, FileReader::SeekSet);
|
||||
auto data = lump.Read();
|
||||
int numsegs = (int)lump.GetLength();
|
||||
auto &segs = level.segs;
|
||||
auto &segs = Level->segs;
|
||||
|
||||
if (!format5 && memcmp(data.Data(), "gNd3", 4))
|
||||
{
|
||||
numsegs/=sizeof(glseg_t);
|
||||
level.segs.Alloc(numsegs);
|
||||
Level->segs.Alloc(numsegs);
|
||||
memset(&segs[0],0,sizeof(seg_t)*numsegs);
|
||||
|
||||
glseg_t * ml = (glseg_t*)data.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))];
|
||||
segs[i].v1 = &Level->vertexes[checkGLVertex(LittleShort(ml->v1))];
|
||||
segs[i].v2 = &Level->vertexes[checkGLVertex(LittleShort(ml->v2))];
|
||||
segs[i].PartnerSeg = ml->partner == 0xFFFF ? nullptr : &segs[LittleShort(ml->partner)];
|
||||
if(ml->linedef != 0xffff)
|
||||
{
|
||||
ldef = &level.lines[LittleShort(ml->linedef)];
|
||||
ldef = &Level->lines[LittleShort(ml->linedef)];
|
||||
segs[i].linedef = ldef;
|
||||
|
||||
|
||||
ml->side=LittleShort(ml->side);
|
||||
segs[i].sidedef = ldef->sidedef[ml->side];
|
||||
if (ldef->sidedef[ml->side] != NULL)
|
||||
if (ldef->sidedef[ml->side] != nullptr)
|
||||
{
|
||||
segs[i].frontsector = ldef->sidedef[ml->side]->sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
segs[i].frontsector = NULL;
|
||||
segs[i].frontsector = nullptr;
|
||||
}
|
||||
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != NULL)
|
||||
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != nullptr)
|
||||
{
|
||||
segs[i].backsector = ldef->sidedef[ml->side^1]->sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
ldef->flags &= ~ML_TWOSIDED;
|
||||
segs[i].backsector = NULL;
|
||||
segs[i].backsector = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
segs[i].linedef = NULL;
|
||||
segs[i].sidedef = NULL;
|
||||
segs[i].linedef = nullptr;
|
||||
segs[i].sidedef = nullptr;
|
||||
|
||||
segs[i].frontsector = NULL;
|
||||
segs[i].backsector = NULL;
|
||||
segs[i].frontsector = nullptr;
|
||||
segs[i].backsector = nullptr;
|
||||
}
|
||||
ml++;
|
||||
}
|
||||
|
@ -343,51 +341,51 @@ static bool LoadGLSegs(FileReader &lump)
|
|||
{
|
||||
if (!format5) numsegs-=4;
|
||||
numsegs/=sizeof(glseg3_t);
|
||||
level.segs.Alloc(numsegs);
|
||||
Level->segs.Alloc(numsegs);
|
||||
memset(&segs[0],0,sizeof(seg_t)*numsegs);
|
||||
|
||||
glseg3_t * ml = (glseg3_t*)(data.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))];
|
||||
segs[i].v1 = &Level->vertexes[checkGLVertex3(LittleLong(ml->v1))];
|
||||
segs[i].v2 = &Level->vertexes[checkGLVertex3(LittleLong(ml->v2))];
|
||||
|
||||
const uint32_t partner = LittleLong(ml->partner);
|
||||
segs[i].PartnerSeg = DWORD_MAX == partner ? nullptr : &segs[partner];
|
||||
|
||||
if(ml->linedef != 0xffff) // skip minisegs
|
||||
{
|
||||
ldef = &level.lines[LittleLong(ml->linedef)];
|
||||
ldef = &Level->lines[LittleLong(ml->linedef)];
|
||||
segs[i].linedef = ldef;
|
||||
|
||||
|
||||
ml->side=LittleShort(ml->side);
|
||||
segs[i].sidedef = ldef->sidedef[ml->side];
|
||||
if (ldef->sidedef[ml->side] != NULL)
|
||||
if (ldef->sidedef[ml->side] != nullptr)
|
||||
{
|
||||
segs[i].frontsector = ldef->sidedef[ml->side]->sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
segs[i].frontsector = NULL;
|
||||
segs[i].frontsector = nullptr;
|
||||
}
|
||||
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != NULL)
|
||||
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != nullptr)
|
||||
{
|
||||
segs[i].backsector = ldef->sidedef[ml->side^1]->sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
ldef->flags &= ~ML_TWOSIDED;
|
||||
segs[i].backsector = NULL;
|
||||
segs[i].backsector = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
segs[i].linedef = NULL;
|
||||
segs[i].sidedef = NULL;
|
||||
segs[i].frontsector = NULL;
|
||||
segs[i].backsector = NULL;
|
||||
segs[i].linedef = nullptr;
|
||||
segs[i].sidedef = nullptr;
|
||||
segs[i].frontsector = nullptr;
|
||||
segs[i].backsector = nullptr;
|
||||
}
|
||||
ml++;
|
||||
}
|
||||
|
@ -402,7 +400,7 @@ static bool LoadGLSegs(FileReader &lump)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool LoadGLSubsectors(FileReader &lump)
|
||||
bool MapLoader::LoadGLSubsectors(FileReader &lump)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -419,14 +417,14 @@ static bool LoadGLSubsectors(FileReader &lump)
|
|||
{
|
||||
mapsubsector_t * data = (mapsubsector_t*) datab.Data();
|
||||
numsubsectors /= sizeof(mapsubsector_t);
|
||||
level.subsectors.Alloc(numsubsectors);
|
||||
auto &subsectors = level.subsectors;
|
||||
Level->subsectors.Alloc(numsubsectors);
|
||||
auto &subsectors = Level->subsectors;
|
||||
memset(&subsectors[0],0,numsubsectors * sizeof(subsector_t));
|
||||
|
||||
for (i=0; i<numsubsectors; i++)
|
||||
{
|
||||
subsectors[i].numlines = LittleShort(data[i].numsegs );
|
||||
subsectors[i].firstline = &level.segs[LittleShort(data[i].firstseg)];
|
||||
subsectors[i].firstline = &Level->segs[LittleShort(data[i].firstseg)];
|
||||
|
||||
if (subsectors[i].numlines == 0)
|
||||
{
|
||||
|
@ -438,14 +436,14 @@ static bool LoadGLSubsectors(FileReader &lump)
|
|||
{
|
||||
gl3_mapsubsector_t * data = (gl3_mapsubsector_t*) (datab.Data()+(format5? 0:4));
|
||||
numsubsectors /= sizeof(gl3_mapsubsector_t);
|
||||
level.subsectors.Alloc(numsubsectors);
|
||||
auto &subsectors = level.subsectors;
|
||||
Level->subsectors.Alloc(numsubsectors);
|
||||
auto &subsectors = Level->subsectors;
|
||||
memset(&subsectors[0],0,numsubsectors * sizeof(subsector_t));
|
||||
|
||||
for (i=0; i<numsubsectors; i++)
|
||||
{
|
||||
subsectors[i].numlines = LittleLong(data[i].numsegs );
|
||||
subsectors[i].firstline = &level.segs[LittleLong(data[i].firstseg)];
|
||||
subsectors[i].firstline = &Level->segs[LittleLong(data[i].firstseg)];
|
||||
|
||||
if (subsectors[i].numlines == 0)
|
||||
{
|
||||
|
@ -454,12 +452,12 @@ static bool LoadGLSubsectors(FileReader &lump)
|
|||
}
|
||||
}
|
||||
|
||||
for (auto &sub : level.subsectors)
|
||||
for (auto &sub : Level->subsectors)
|
||||
{
|
||||
for(unsigned j=0;j<sub.numlines;j++)
|
||||
{
|
||||
seg_t * seg = sub.firstline + j;
|
||||
if (seg->linedef==NULL) seg->frontsector = seg->backsector = sub.firstline->frontsector;
|
||||
if (seg->linedef==nullptr) seg->frontsector = seg->backsector = sub.firstline->frontsector;
|
||||
}
|
||||
seg_t *firstseg = sub.firstline;
|
||||
seg_t *lastseg = sub.firstline + sub.numlines - 1;
|
||||
|
@ -479,7 +477,7 @@ static bool LoadGLSubsectors(FileReader &lump)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool LoadNodes (FileReader &lump)
|
||||
bool MapLoader::LoadNodes (FileReader &lump)
|
||||
{
|
||||
const int NF_SUBSECTOR = 0x8000;
|
||||
const int GL5_NF_SUBSECTOR = (1 << 31);
|
||||
|
@ -496,7 +494,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
|
||||
if (numnodes == 0) return false;
|
||||
|
||||
level.nodes.Alloc(numnodes);
|
||||
Level->nodes.Alloc(numnodes);
|
||||
lump.Seek(0, FileReader::SeekSet);
|
||||
|
||||
auto buf = lump.Read();
|
||||
|
@ -505,7 +503,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
used.Resize(numnodes);
|
||||
memset (used.Data(), 0, sizeof(uint16_t)*numnodes);
|
||||
|
||||
no = &level.nodes[0];
|
||||
no = &Level->nodes[0];
|
||||
|
||||
for (unsigned i = 0; i < numnodes; i++, no++, mn++)
|
||||
{
|
||||
|
@ -519,11 +517,11 @@ static bool LoadNodes (FileReader &lump)
|
|||
if (child & NF_SUBSECTOR)
|
||||
{
|
||||
child &= ~NF_SUBSECTOR;
|
||||
if (child >= level.subsectors.Size())
|
||||
if (child >= Level->subsectors.Size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
||||
no->children[j] = (uint8_t *)&Level->subsectors[child] + 1;
|
||||
}
|
||||
else if (child >= numnodes)
|
||||
{
|
||||
|
@ -535,7 +533,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
}
|
||||
else
|
||||
{
|
||||
no->children[j] = &level.nodes[child];
|
||||
no->children[j] = &Level->nodes[child];
|
||||
used[child] = j + 1;
|
||||
}
|
||||
for (k = 0; k < 4; k++)
|
||||
|
@ -552,7 +550,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
|
||||
if (numnodes == 0) return false;
|
||||
|
||||
level.nodes.Alloc(numnodes);
|
||||
Level->nodes.Alloc(numnodes);
|
||||
lump.Seek(0, FileReader::SeekSet);
|
||||
|
||||
auto buf = lump.Read();
|
||||
|
@ -561,7 +559,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
used.Resize(numnodes);
|
||||
memset(used.Data(), 0, sizeof(uint16_t)*numnodes);
|
||||
|
||||
no = &level.nodes[0];
|
||||
no = &Level->nodes[0];
|
||||
|
||||
for (unsigned i = 0; i < numnodes; i++, no++, mn++)
|
||||
{
|
||||
|
@ -575,11 +573,11 @@ static bool LoadNodes (FileReader &lump)
|
|||
if (child & GL5_NF_SUBSECTOR)
|
||||
{
|
||||
child &= ~GL5_NF_SUBSECTOR;
|
||||
if ((unsigned)child >= level.subsectors.Size())
|
||||
if ((unsigned)child >= Level->subsectors.Size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
||||
no->children[j] = (uint8_t *)&Level->subsectors[child] + 1;
|
||||
}
|
||||
else if ((unsigned)child >= numnodes)
|
||||
{
|
||||
|
@ -591,7 +589,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
}
|
||||
else
|
||||
{
|
||||
no->children[j] = &level.nodes[child];
|
||||
no->children[j] = &Level->nodes[child];
|
||||
used[child] = j + 1;
|
||||
}
|
||||
for (k = 0; k < 4; k++)
|
||||
|
@ -610,7 +608,7 @@ static bool LoadNodes (FileReader &lump)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool DoLoadGLNodes(FileReader * lumps)
|
||||
bool MapLoader::DoLoadGLNodes(FileReader * lumps)
|
||||
{
|
||||
int missing = 0;
|
||||
|
||||
|
@ -625,7 +623,7 @@ static bool DoLoadGLNodes(FileReader * lumps)
|
|||
// Quick check for the validity of the nodes
|
||||
// For invalid nodes there is a high chance that this test will fail
|
||||
|
||||
for (auto &sub : level.subsectors)
|
||||
for (auto &sub : Level->subsectors)
|
||||
{
|
||||
seg_t * seg = sub.firstline;
|
||||
if (!seg->sidedef)
|
||||
|
@ -644,9 +642,9 @@ static bool DoLoadGLNodes(FileReader * lumps)
|
|||
return missing == 0;
|
||||
|
||||
fail:
|
||||
level.nodes.Clear();
|
||||
level.subsectors.Clear();
|
||||
level.segs.Clear();
|
||||
Level->nodes.Clear();
|
||||
Level->subsectors.Clear();
|
||||
Level->segs.Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -723,7 +721,7 @@ static int FindGLNodesInWAD(int labellump)
|
|||
//
|
||||
// Looks for GL nodes in the same WAD as the level itself
|
||||
// Function returns the lump number within the file. Returns -1 if the input
|
||||
// resource file is NULL.
|
||||
// resource file is nullptr.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
|
@ -840,7 +838,7 @@ bool MapLoader::LoadGLNodes(MapData * map)
|
|||
// Todo: Compare file dates
|
||||
|
||||
f_gwa = FResourceFile::OpenResourceFile(path, true);
|
||||
if (f_gwa==NULL) return false;
|
||||
if (f_gwa==nullptr) return false;
|
||||
|
||||
strncpy(map->MapLumps[0].Name, Wads.GetLumpFullName(map->lumpnum), 8);
|
||||
}
|
||||
|
@ -885,7 +883,7 @@ bool MapLoader::CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
|||
bool loaded = false;
|
||||
|
||||
// If the map loading code has performed a node rebuild we don't need to check for it again.
|
||||
if (!rebuilt && !P_CheckForGLNodes())
|
||||
if (!rebuilt && !CheckForGLNodes())
|
||||
{
|
||||
ret = true; // we are not using the level's original nodes if we get here.
|
||||
for (auto &sub : Level->subsectors)
|
||||
|
@ -988,26 +986,26 @@ static void WriteLong(MemFile &f, uint32_t b)
|
|||
f[v+3] = (uint8_t)(b>>24);
|
||||
}
|
||||
|
||||
static void CreateCachedNodes(MapData *map)
|
||||
void MapLoader::CreateCachedNodes(MapData *map)
|
||||
{
|
||||
MemFile ZNodes;
|
||||
|
||||
WriteLong(ZNodes, 0);
|
||||
WriteLong(ZNodes, level.vertexes.Size());
|
||||
for(auto &vert : level.vertexes)
|
||||
WriteLong(ZNodes, Level->vertexes.Size());
|
||||
for(auto &vert : Level->vertexes)
|
||||
{
|
||||
WriteLong(ZNodes, vert.fixX());
|
||||
WriteLong(ZNodes, vert.fixY());
|
||||
}
|
||||
|
||||
WriteLong(ZNodes, level.subsectors.Size());
|
||||
for (auto &sub : level.subsectors)
|
||||
WriteLong(ZNodes, Level->subsectors.Size());
|
||||
for (auto &sub : Level->subsectors)
|
||||
{
|
||||
WriteLong(ZNodes, sub.numlines);
|
||||
}
|
||||
|
||||
WriteLong(ZNodes, level.segs.Size());
|
||||
for(auto &seg : level.segs)
|
||||
WriteLong(ZNodes, Level->segs.Size());
|
||||
for(auto &seg : Level->segs)
|
||||
{
|
||||
WriteLong(ZNodes, seg.v1->Index());
|
||||
WriteLong(ZNodes, seg.PartnerSeg == nullptr? 0xffffffffu : uint32_t(seg.PartnerSeg->Index()));
|
||||
|
@ -1023,8 +1021,8 @@ static void CreateCachedNodes(MapData *map)
|
|||
}
|
||||
}
|
||||
|
||||
WriteLong(ZNodes, level.nodes.Size());
|
||||
for(auto &node : level.nodes)
|
||||
WriteLong(ZNodes, Level->nodes.Size());
|
||||
for(auto &node : Level->nodes)
|
||||
{
|
||||
WriteLong(ZNodes, node.x);
|
||||
WriteLong(ZNodes, node.y);
|
||||
|
@ -1055,7 +1053,7 @@ static void CreateCachedNodes(MapData *map)
|
|||
|
||||
uLongf outlen = ZNodes.Size();
|
||||
TArray<Bytef> compressed;
|
||||
int offset = level.lines.Size() * 8 + 12 + 16;
|
||||
int offset = Level->lines.Size() * 8 + 12 + 16;
|
||||
int r;
|
||||
do
|
||||
{
|
||||
|
@ -1069,12 +1067,12 @@ static void CreateCachedNodes(MapData *map)
|
|||
while (r == Z_BUF_ERROR);
|
||||
|
||||
memcpy(compressed.Data(), "CACH", 4);
|
||||
uint32_t len = LittleLong(level.lines.Size());
|
||||
uint32_t len = LittleLong(Level->lines.Size());
|
||||
memcpy(&compressed[4], &len, 4);
|
||||
map->GetChecksum(&compressed[8]);
|
||||
for (unsigned i = 0; i < level.lines.Size(); i++)
|
||||
for (unsigned i = 0; i < Level->lines.Size(); i++)
|
||||
{
|
||||
uint32_t ndx[2] = { LittleLong(uint32_t(level.lines[i].v1->Index())), LittleLong(uint32_t(level.lines[i].v2->Index())) };
|
||||
uint32_t ndx[2] = { LittleLong(uint32_t(Level->lines[i].v1->Index())), LittleLong(uint32_t(Level->lines[i].v2->Index())) };
|
||||
memcpy(&compressed[8 + 16 + 8 * i], ndx, 8);
|
||||
}
|
||||
memcpy(&compressed[offset - 4], "ZGL3", 4);
|
||||
|
@ -1246,7 +1244,7 @@ static bool PointOnLine (int x, int y, int x1, int y1, int dx, int dy)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void P_SetRenderSector()
|
||||
void MapLoader::SetRenderSector()
|
||||
{
|
||||
int i;
|
||||
uint32_t j;
|
||||
|
@ -1255,14 +1253,14 @@ void P_SetRenderSector()
|
|||
|
||||
// Check for incorrect partner seg info so that the following code does not crash.
|
||||
|
||||
for (auto &seg : level.segs)
|
||||
for (auto &seg : Level->segs)
|
||||
{
|
||||
auto p = seg.PartnerSeg;
|
||||
if (p != nullptr)
|
||||
{
|
||||
int partner = p->Index();
|
||||
|
||||
if (partner < 0 || partner >= (int)level.segs.Size() || &level.segs[partner] != p)
|
||||
if (partner < 0 || partner >= (int)Level->segs.Size() || &Level->segs[partner] != p)
|
||||
{
|
||||
seg.PartnerSeg = nullptr;
|
||||
}
|
||||
|
@ -1274,7 +1272,7 @@ void P_SetRenderSector()
|
|||
}
|
||||
}
|
||||
}
|
||||
for (auto &seg : level.segs)
|
||||
for (auto &seg : Level->segs)
|
||||
{
|
||||
if (seg.PartnerSeg != nullptr && seg.PartnerSeg->PartnerSeg != &seg)
|
||||
{
|
||||
|
@ -1283,7 +1281,7 @@ void P_SetRenderSector()
|
|||
}
|
||||
|
||||
// look up sector number for each subsector
|
||||
for (auto &ss : level.subsectors)
|
||||
for (auto &ss : Level->subsectors)
|
||||
{
|
||||
// For rendering pick the sector from the first seg that is a sector boundary
|
||||
// this takes care of self-referencing sectors
|
||||
|
@ -1312,7 +1310,7 @@ void P_SetRenderSector()
|
|||
}
|
||||
seg++;
|
||||
}
|
||||
if(ss.render_sector == NULL)
|
||||
if(ss.render_sector == nullptr)
|
||||
{
|
||||
undetermined.Push(&ss);
|
||||
}
|
||||
|
|
|
@ -3011,16 +3011,15 @@ void MapLoader::AddToList(uint8_t *hitlist, FTextureID texid, int bitmask)
|
|||
|
||||
void MapLoader::PrecacheLevel()
|
||||
{
|
||||
int i;
|
||||
uint8_t *hitlist;
|
||||
TMap<PClassActor *, bool> actorhitlist;
|
||||
int cnt = TexMan.NumTextures();
|
||||
|
||||
if (demoplayback)
|
||||
return;
|
||||
|
||||
hitlist = new uint8_t[cnt];
|
||||
memset(hitlist, 0, cnt);
|
||||
int i;
|
||||
TMap<PClassActor *, bool> actorhitlist;
|
||||
int cnt = TexMan.NumTextures();
|
||||
TArray<uint8_t> hitlist(cnt, true);
|
||||
|
||||
memset(hitlist.Data(), 0, cnt);
|
||||
|
||||
AActor *actor;
|
||||
TThinkerIterator<AActor> iterator;
|
||||
|
@ -3044,15 +3043,15 @@ void MapLoader::PrecacheLevel()
|
|||
|
||||
for (i = Level->sectors.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
AddToList(hitlist, Level->sectors[i].GetTexture(sector_t::floor), FTextureManager::HIT_Flat);
|
||||
AddToList(hitlist, Level->sectors[i].GetTexture(sector_t::ceiling), FTextureManager::HIT_Flat);
|
||||
AddToList(hitlist.Data(), Level->sectors[i].GetTexture(sector_t::floor), FTextureManager::HIT_Flat);
|
||||
AddToList(hitlist.Data(), Level->sectors[i].GetTexture(sector_t::ceiling), FTextureManager::HIT_Flat);
|
||||
}
|
||||
|
||||
for (i = Level->sides.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
AddToList(hitlist, Level->sides[i].GetTexture(side_t::top), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist, Level->sides[i].GetTexture(side_t::mid), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist, Level->sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::top), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::mid), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall);
|
||||
}
|
||||
|
||||
// Sky texture is always present.
|
||||
|
@ -3064,31 +3063,30 @@ void MapLoader::PrecacheLevel()
|
|||
|
||||
if (sky1texture.isValid())
|
||||
{
|
||||
AddToList(hitlist, sky1texture, FTextureManager::HIT_Sky);
|
||||
AddToList(hitlist.Data(), sky1texture, FTextureManager::HIT_Sky);
|
||||
}
|
||||
if (sky2texture.isValid())
|
||||
{
|
||||
AddToList(hitlist, sky2texture, FTextureManager::HIT_Sky);
|
||||
AddToList(hitlist.Data(), sky2texture, FTextureManager::HIT_Sky);
|
||||
}
|
||||
|
||||
for (auto n : gameinfo.PrecachedTextures)
|
||||
{
|
||||
FTextureID tex = TexMan.CheckForTexture(n, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (tex.Exists()) AddToList(hitlist, tex, FTextureManager::HIT_Wall);
|
||||
if (tex.Exists()) AddToList(hitlist.Data(), tex, FTextureManager::HIT_Wall);
|
||||
}
|
||||
for (unsigned i = 0; i < Level->info->PrecacheTextures.Size(); i++)
|
||||
{
|
||||
FTextureID tex = TexMan.CheckForTexture(Level->info->PrecacheTextures[i], ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (tex.Exists()) AddToList(hitlist, tex, FTextureManager::HIT_Wall);
|
||||
if (tex.Exists()) AddToList(hitlist.Data(), tex, FTextureManager::HIT_Wall);
|
||||
}
|
||||
|
||||
// This is just a temporary solution, until the hardware renderer's texture manager is in a better state.
|
||||
if (!V_IsHardwareRenderer())
|
||||
SWRenderer->Precache(hitlist, actorhitlist);
|
||||
SWRenderer->Precache(hitlist.Data(), actorhitlist);
|
||||
else
|
||||
hw_PrecacheTexture(hitlist, actorhitlist);
|
||||
hw_PrecacheTexture(hitlist.Data(), actorhitlist);
|
||||
|
||||
delete[] hitlist;
|
||||
}
|
||||
|
||||
extern polyblock_t **PolyBlockMap;
|
||||
|
@ -3628,7 +3626,7 @@ void P_SetupLevel(const char *lumpname, int position, bool newGame)
|
|||
}
|
||||
else
|
||||
{
|
||||
P_CheckForGLNodes();
|
||||
loader.CheckForGLNodes();
|
||||
}
|
||||
|
||||
// set the head node for gameplay purposes. If the separate gamenodes array is not empty, use that, otherwise use the render nodes.
|
||||
|
@ -3650,7 +3648,7 @@ void P_SetupLevel(const char *lumpname, int position, bool newGame)
|
|||
loader.FloodZones();
|
||||
times[13].Unclock();
|
||||
|
||||
P_SetRenderSector();
|
||||
loader.SetRenderSector();
|
||||
FixMinisegReferences();
|
||||
FixHoles();
|
||||
|
||||
|
|
|
@ -165,8 +165,6 @@ int GetUDMFInt(int type, int index, FName key);
|
|||
double GetUDMFFloat(int type, int index, FName key);
|
||||
FString GetUDMFString(int type, int index, FName key);
|
||||
|
||||
bool P_CheckForGLNodes();
|
||||
void P_SetRenderSector();
|
||||
void FixMinisegReferences();
|
||||
void FixHoles();
|
||||
void ReportUnpairedMinisegs();
|
||||
|
@ -213,6 +211,20 @@ class MapLoader
|
|||
void *level; // this is to hide the global variable and produce an error for referencing it.
|
||||
FLevelLocals *Level;
|
||||
|
||||
int firstglvertex; // helpers for loading GL nodes from GWA files.
|
||||
bool format5;
|
||||
|
||||
|
||||
int checkGLVertex(int num);
|
||||
int checkGLVertex3(int num);
|
||||
int CheckForMissingSegs();
|
||||
bool LoadGLVertexes(FileReader &lump);
|
||||
bool LoadGLSegs(FileReader &lump);
|
||||
bool LoadGLSubsectors(FileReader &lump);
|
||||
bool LoadNodes(FileReader &lump);
|
||||
bool DoLoadGLNodes(FileReader * lumps);
|
||||
void CreateCachedNodes(MapData *map);
|
||||
|
||||
void SetTexture(side_t *side, int position, const char *name, FMissingTextureTracker &track);
|
||||
void SetTexture(sector_t *sector, int index, int position, const char *name, FMissingTextureTracker &track, bool truncate);
|
||||
void SetTexture(side_t *side, int position, uint32_t *blend, const char *name);
|
||||
|
@ -245,6 +257,7 @@ public:
|
|||
bool LoadGLNodes(MapData * map);
|
||||
bool CheckCachedNodes(MapData *map);
|
||||
bool CheckNodes(MapData * map, bool rebuilt, int buildtime);
|
||||
bool CheckForGLNodes();
|
||||
|
||||
void LoadSectors(MapData *map, FMissingTextureTracker &missingtex);
|
||||
void LoadThings(MapData * map);
|
||||
|
@ -264,6 +277,7 @@ public:
|
|||
void PrecacheLevel();
|
||||
void ParseTextMap(MapData *map, FMissingTextureTracker &missingtex);
|
||||
void SummarizeMissingTextures(const FMissingTextureTracker &missing);
|
||||
void SetRenderSector();
|
||||
|
||||
MapLoader(FLevelLocals *lev)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue