diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 05ed781600..f3d594e5a2 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -53,8 +53,10 @@ struct FLevelData TArray vertexes; TArray sectors; TArray linebuffer; // contains the line lists for the sectors. + TArray subsectorbuffer; // contains the subsector lists for the sectors. TArray lines; TArray sides; + TArray segbuffer; // contains the seg links for the sidedefs. TArray segs; TArray subsectors; TArray nodes; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 9e372b0594..1dcc4eb664 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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(); diff --git a/src/r_data/renderinfo.cpp b/src/r_data/renderinfo.cpp index 0a058b10ca..753bf7cb4e 100644 --- a/src/r_data/renderinfo.cpp +++ b/src/r_data/renderinfo.cpp @@ -243,13 +243,14 @@ static void PrepareSectorData() TArray 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++) diff --git a/src/r_defs.h b/src/r_defs.h index 3f54190eb9..74c020b990 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -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 diff --git a/src/tarray.h b/src/tarray.h index 1c5faca437..3ecdf67f19 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -1460,17 +1460,9 @@ public: Count = count; Array = data; } - TArrayView(const TArrayView &other) - { - Count = other.Count; - Array = other.Array; - } - TArrayView &operator= (const TArrayView &other) - { - Count = other.Count; - Array = other.Array; - return *this; - } + TArrayView(const TArrayView &other) = default; + TArrayView &operator= (const TArrayView &other) = default; + // Check equality of two arrays bool operator==(const TArrayView &other) const {