fix: GameDataScrounger treats ignored files as abstract (#44467)

* fix: GameDataScrounger properly ignores ignore-list

* refactor: GDC to treat ignored files as abstract

* fix: use wizden's fix for windows

* refactor: check ignoredDir first for perf and readability
This commit is contained in:
Falcon 2026-07-16 08:31:28 -07:00 • committed by GitHub
parent f89513d4d4
commit 886df83242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -169,17 +169,15 @@ public static partial class GameDataScrounger
// Take a directory off the stack.
var dir = explorationStack.Pop();
if (ignoreList.Contains(Path.GetFullPath(dir)))
continue; // It's all abstract anyway.
var ignoredDir = ignoreList.Contains(Path.GetFullPath(dir));
explorationStack.AddRange(Directory.EnumerateDirectories(dir));
foreach (var file in Directory.EnumerateFiles(dir, "*.yml"))
{
if (ignoreList.Contains(Path.GetFullPath(file)))
continue; // It's all abstract anyway.
var ignored = ignoredDir || ignoreList.Contains(Path.GetFullPath(file));
foreach (var (kind, id) in IndexPrototypesIn(file))
foreach (var (kind, id) in IndexPrototypesIn(file, ignored))
{
// alternate universe where .net has rust's Entry api.
if (!_prototypeIndex.TryGetValue(kind, out var list))
@ -204,8 +202,9 @@ public static partial class GameDataScrounger
/// yielding all (type, id) pairs.
/// </summary>
/// <param name="file">The file to index.</param>
/// <param name="ignored">Whether or not the file is ignored. This treats the entire file as abstract.</param>
/// <returns>An enumerator of all prototypes in the file, regardless of kind.</returns>
private static IEnumerable<(string type, string id)> IndexPrototypesIn(string file)
private static IEnumerable<(string type, string id)> IndexPrototypesIn(string file, bool ignored = false)
{
var stream = new YamlStream();
@ -223,7 +222,7 @@ public static partial class GameDataScrounger
var id = entryMapping[IdNode];
var type = entryMapping[TypeNode];
var @abstract = false;
var @abstract = ignored;
if (entryMapping.TryGetNode("abstract", out YamlScalarNode? abstractNode))
{
// TODO: This technically will exclude prototypes that use the abstract field for their own stuff,