- store the master pointer for the subsector lists in sector_t and the seg lists in side_t in FLevelLocals as a TArray instead of relying on the first element's pointer for this.

This simply way bad style.
This commit is contained in:
Christoph Oelckers 2018-12-28 14:24:22 +01:00
parent 64595abe60
commit 326e4d8559
5 changed files with 14 additions and 30 deletions

View file

@ -53,8 +53,10 @@ struct FLevelData
TArray<vertex_t> vertexes;
TArray<sector_t> sectors;
TArray<line_t*> linebuffer; // contains the line lists for the sectors.
TArray<subsector_t*> subsectorbuffer; // contains the subsector lists for the sectors.
TArray<line_t> lines;
TArray<side_t> sides;
TArray<seg_t *> segbuffer; // contains the seg links for the sidedefs.
TArray<seg_t> segs;
TArray<subsector_t> subsectors;
TArray<node_t> nodes;

View file

@ -250,30 +250,22 @@ void P_FreeLevelData ()
if (level.sectors.Size() > 0)
{
delete[] level.sectors[0].e;
if (level.sectors[0].subsectors)
{
delete[] level.sectors[0].subsectors;
level.sectors[0].subsectors = nullptr;
}
}
for (auto &sub : level.subsectors)
{
if (sub.BSP != nullptr) delete sub.BSP;
}
if (level.sides.Size() > 0 && level.sides[0].segs)
{
delete[] level.sides[0].segs;
level.sides[0].segs = nullptr;
}
FBehavior::StaticUnloadModules ();
level.canvasTextureInfo.EmptyList();
level.sections.Clear();
level.segs.Clear();
level.sectors.Clear();
level.linebuffer.Clear();
level.subsectorbuffer.Clear();
level.lines.Clear();
level.sides.Clear();
level.segbuffer.Clear();
level.loadsectors.Clear();
level.loadlines.Clear();
level.loadsides.Clear();

View file

@ -243,13 +243,14 @@ static void PrepareSectorData()
TArray<subsector_t *> undetermined;
// now group the subsectors by sector
subsector_t ** subsectorbuffer = new subsector_t * [level.subsectors.Size()];
level.subsectorbuffer.Resize(level.subsectors.Size());
for (auto &sub : level.subsectors)
{
sub.render_sector->subsectorcount++;
}
auto subsectorbuffer = level.subsectorbuffer.Data();
for (auto &sec : level.sectors)
{
sec.subsectors = subsectorbuffer;
@ -499,7 +500,8 @@ static void PrepareSegs()
}
// allocate memory
level.sides[0].segs = new seg_t*[realsegs];
level.segbuffer.Resize(realsegs);
level.sides[0].segs = level.segbuffer.Data();
level.sides[0].numsegs = 0;
for(unsigned i = 1; i < numsides; i++)

View file

@ -1183,6 +1183,8 @@ struct side_t
uint8_t Flags;
int UDMFIndex; // needed to access custom UDMF fields which are stored in loading order.
FLightNode * lighthead; // all dynamic lights that may affect this wall
seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering
int numsegs;
int GetLightLevel (bool foggy, int baselight, bool is3dlight=false, int *pfakecontrast_usedbygzdoom=NULL) const;
@ -1342,12 +1344,6 @@ struct side_t
vertex_t *V2() const;
int Index() const;
//For GL
seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering
int numsegs;
};
enum AutomapLineStyle : int

View file

@ -1460,17 +1460,9 @@ public:
Count = count;
Array = data;
}
TArrayView(const TArrayView<T> &other)
{
Count = other.Count;
Array = other.Array;
}
TArrayView<T> &operator= (const TArrayView<T> &other)
{
Count = other.Count;
Array = other.Array;
return *this;
}
TArrayView(const TArrayView<T> &other) = default;
TArrayView<T> &operator= (const TArrayView<T> &other) = default;
// Check equality of two arrays
bool operator==(const TArrayView<T> &other) const
{