Skip to content

Commit 8eb150f

Browse files
committed
Fix dependency collector to not collect empty lists
1 parent d2d8949 commit 8eb150f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

YAFCmodel/Analysis/Dependencies.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,21 @@ private class DependencyCollector : IDependencyCollector
6565
{
6666
private readonly List<DependencyList> list = new List<DependencyList>();
6767

68-
public void Add(FactorioId[] raw, DependencyList.Flags flags)
68+
public void Add(FactorioId[] elements, DependencyList.Flags flags)
6969
{
70-
list.Add(new DependencyList {elements = raw, flags = flags});
70+
// Only add lists that actually contain elements, lists that are used to hide objects, or lists to unlock technologies (because of the lack of unlocking dependencies those should be unavailable)
71+
if (elements.Length > 0 || flags == DependencyList.Flags.Hidden || flags == DependencyList.Flags.TechnologyUnlock)
72+
{
73+
list.Add(new DependencyList { elements = elements, flags = flags });
74+
}
7175
}
7276

73-
public void Add(IReadOnlyList<FactorioObject> raw, DependencyList.Flags flags)
77+
public void Add(IReadOnlyList<FactorioObject> readOnlyList, DependencyList.Flags flags)
7478
{
75-
var elems = new FactorioId[raw.Count];
76-
for (var i = 0; i < raw.Count; i++)
77-
elems[i] = raw[i].id;
78-
list.Add(new DependencyList {elements = elems, flags = flags});
79+
var elems = new FactorioId[readOnlyList.Count];
80+
for (var i = 0; i < readOnlyList.Count; i++)
81+
elems[i] = readOnlyList[i].id;
82+
Add(elems, flags);
7983
}
8084

8185
public DependencyList[] Pack()

YAFCmodel/Analysis/Milestones.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ public void ComputeWithParameters(Project project, ErrorCollector warnings, Fact
188188
{
189189
if (list.elements.Length == 0)
190190
{
191-
Console.WriteLine("Unexpected: {0} ({1}) [{2}] - {3} group deps empty, will cause unreachable elements", Database.objects[elem].name, Database.objects[elem].id, Database.objects[elem].GetType().Name, list.flags);
191+
if ((list.flags & DependencyList.Flags.Hidden) != DependencyList.Flags.Hidden && (list.flags & DependencyList.Flags.TechnologyUnlock) != DependencyList.Flags.TechnologyUnlock)
192+
{
193+
Console.WriteLine("Unexpected: {0} ({1}) [{2}] - {3} group deps empty, will cause unreachable elements", Database.objects[elem].name, Database.objects[elem].id, Database.objects[elem].GetType().Name, list.flags);
194+
}
192195
}
193196

194197
// Minimize group (dependency) cost

0 commit comments

Comments
 (0)