mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-01-30 20:50:41 +00:00
Replace most big foreach loops by for loops in MapSet
This commit is contained in:
parent
e3752e8601
commit
b54d7a48cc
1 changed files with 20 additions and 11 deletions
|
@ -2199,10 +2199,12 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
List<LinedefSide> edges = new List<LinedefSide>();
|
List<LinedefSide> edges = new List<LinedefSide>();
|
||||||
if(existing_only)
|
if(existing_only)
|
||||||
{
|
{
|
||||||
foreach(Linedef l in lines)
|
int lineCount = lines.Count;
|
||||||
|
for (int i = 0; i < lineCount; i++)
|
||||||
{
|
{
|
||||||
|
Linedef l = lines[i];
|
||||||
// Add only existing sides as edges (or front side if line has none)
|
// Add only existing sides as edges (or front side if line has none)
|
||||||
if(l.Front != null || l.Back == null)
|
if (l.Front != null || l.Back == null)
|
||||||
edges.Add(new LinedefSide(l, true));
|
edges.Add(new LinedefSide(l, true));
|
||||||
if(l.Back != null)
|
if(l.Back != null)
|
||||||
edges.Add(new LinedefSide(l, false));
|
edges.Add(new LinedefSide(l, false));
|
||||||
|
@ -2210,8 +2212,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach(Linedef l in lines)
|
int lineCount = lines.Count;
|
||||||
|
for (int i = 0; i < lineCount; i++)
|
||||||
{
|
{
|
||||||
|
Linedef l = lines[i];
|
||||||
// Add front side
|
// Add front side
|
||||||
edges.Add(new LinedefSide(l, true));
|
edges.Add(new LinedefSide(l, true));
|
||||||
|
|
||||||
|
@ -2222,9 +2226,11 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<Sidedef> sides_correct = new HashSet<Sidedef>();
|
HashSet<Sidedef> sides_correct = new HashSet<Sidedef>();
|
||||||
foreach(LinedefSide ls in edges)
|
int edgeCount = edges.Count;
|
||||||
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
if(ls.Front && ls.Line.Front != null)
|
LinedefSide ls = edges[i];
|
||||||
|
if (ls.Front && ls.Line.Front != null)
|
||||||
sides_correct.Add(ls.Line.Front);
|
sides_correct.Add(ls.Line.Front);
|
||||||
else if(!ls.Front && ls.Line.Back != null)
|
else if(!ls.Front && ls.Line.Back != null)
|
||||||
sides_correct.Add(ls.Line.Back);
|
sides_correct.Add(ls.Line.Back);
|
||||||
|
@ -2242,11 +2248,12 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
SectorBuilder builder = new SectorBuilder();
|
SectorBuilder builder = new SectorBuilder();
|
||||||
List<Sector> sectors_reused = new List<Sector>();
|
List<Sector> sectors_reused = new List<Sector>();
|
||||||
|
|
||||||
foreach(LinedefSide ls in edges)
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
|
LinedefSide ls = edges[i];
|
||||||
// Skip if edge is ignored
|
// Skip if edge is ignored
|
||||||
//DebugConsole.WriteLine((ls.Ignore ? "Ignoring line " : "Processing line ") + ls.Line.Index);
|
//DebugConsole.WriteLine((ls.Ignore ? "Ignoring line " : "Processing line ") + ls.Line.Index);
|
||||||
if(ls.Ignore) continue;
|
if (ls.Ignore) continue;
|
||||||
|
|
||||||
// Run sector builder on current edge
|
// Run sector builder on current edge
|
||||||
if(!builder.TraceSector(ls.Line, ls.Front)) continue; // Don't create sector if trace failed
|
if(!builder.TraceSector(ls.Line, ls.Front)) continue; // Don't create sector if trace failed
|
||||||
|
@ -2264,9 +2271,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
if(side_exists && sectorsides.Contains(edge.Front ? edge.Line.Front : edge.Line.Back))
|
if(side_exists && sectorsides.Contains(edge.Front ? edge.Line.Front : edge.Line.Back))
|
||||||
has_dragged_sides = true; //mxd
|
has_dragged_sides = true; //mxd
|
||||||
|
|
||||||
foreach(LinedefSide ls2 in edges)
|
for (int k = 0; k < edgeCount; k++)
|
||||||
{
|
{
|
||||||
if(ls2.Line == edge.Line)
|
LinedefSide ls2 = edges[k];
|
||||||
|
if (ls2.Line == edge.Line)
|
||||||
{
|
{
|
||||||
line_is_ours = true;
|
line_is_ours = true;
|
||||||
if(ls2.Front == edge.Front)
|
if(ls2.Front == edge.Front)
|
||||||
|
@ -2332,9 +2340,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any sides that weren't part of a sector
|
// Remove any sides that weren't part of a sector
|
||||||
foreach(LinedefSide ls in edges)
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
if(ls.Ignore || ls.Line == null) continue;
|
LinedefSide ls = edges[i];
|
||||||
|
if (ls.Ignore || ls.Line == null) continue;
|
||||||
|
|
||||||
if(ls.Front)
|
if(ls.Front)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue