Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions Robust.Packaging/AssetProcessing/Passes/AssetPassPackRsis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public sealed class AssetPassPackRsis : AssetPass

private static readonly Regex RegexMetaJson = new(@"^(.+)\.rsi/meta\.json$");
private static readonly Regex RegexPng = new(@"^(.+)\.rsi/(.+)\.png$");
private static readonly object ConsoleLock = new object();

private readonly Configuration _imageConfiguration;

Expand Down Expand Up @@ -48,18 +47,14 @@ protected override AssetFileAcceptResult AcceptFile(AssetFile file)

// .rsi/*.png
var matchPng = RegexPng.Match(file.Path);
if (matchPng.Success)
if (!matchPng.Success) return AssetFileAcceptResult.Pass;
lock (_foundRsis)
{
lock (_foundRsis)
{
var dat = _foundRsis.GetOrNew(matchPng.Groups[1].Value);
dat.StatesFound[matchPng.Groups[2].Value] = file; //overwrite

return AssetFileAcceptResult.Consumed;
}
var dat = _foundRsis.GetOrNew(matchPng.Groups[1].Value);
if (dat.StatesFound.TryAdd(matchPng.Groups[2].Value, file)) return AssetFileAcceptResult.Consumed;
dat.StatesFound[matchPng.Groups[2].Value] = file;
return AssetFileAcceptResult.Consumed;
}

return AssetFileAcceptResult.Pass;
}

protected override void AcceptFinished()
Expand Down Expand Up @@ -121,10 +116,7 @@ private void SkipRsiPack(RsiDat dat)
sheet.Metadata.GetPngMetadata().TextData.Add(new PngTextData(RsiLoading.RsicPngField, metaJson, "", ""));
sheet.SaveAsPng(ms);

lock (ConsoleLock)
{
Logger?.Verbose($"Done packing {rsiPath}");
}
Logger?.Verbose($"Done packing {rsiPath}");

return new AssetFileMemory($"{rsiPath}c", ms.ToArray());
}
Expand Down
5 changes: 3 additions & 2 deletions Robust.Packaging/RobustServerPackaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ public static async Task WriteServerResources(
CancellationToken cancel = default)
{
var ignoreSet = ServerIgnoresResources.Union(RobustSharedPackaging.SharedIgnoredResources).ToHashSet();
var sharedIgnoreSet = ignoreSet.Union(additionalIgnoredResources).ToHashSet();

await RobustSharedPackaging.DoResourceCopy(
Path.Combine(contentDir, "Resources"),
pass,
ignoreSet.Union(additionalIgnoredResources).ToHashSet(),
sharedIgnoreSet,
cancel: cancel);

await RobustSharedPackaging.DoResourceCopy(
Expand All @@ -41,6 +42,6 @@ await RobustSharedPackaging.DoResourceCopy(
ignoreSet,
cancel: cancel);

await RobustSharedPackaging.DoModularResourceCopy(contentDir, pass, ignoreSet.Union(additionalIgnoredResources).ToHashSet(), cancel);
await RobustSharedPackaging.DoModularResourceCopy(contentDir, pass, sharedIgnoreSet, cancel);
}
}
19 changes: 11 additions & 8 deletions Robust.Packaging/RobustSharedPackaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ public static Task DoModularResourceCopy(
HashSet<string> ignoreSet,
CancellationToken cancel = default)
{
var dirs = Directory.GetDirectories(Path.Combine(contentDir, "Modules"));
foreach (var dir in dirs)
{
var resourcesPath = Path.Combine(dir, "Resources");
if (!Directory.Exists(resourcesPath))
continue;
DoResourceCopy(resourcesPath, pass, ignoreSet, "", cancel);
}
var modulePath = Path.Combine(contentDir, "Modules");
if (!Directory.Exists(modulePath))
return Task.CompletedTask;
Parallel.ForEach(Directory.GetDirectories(modulePath),
dir=>
{
var resourcesPath = Path.Combine(dir, "Resources");
if (!Directory.Exists(resourcesPath))
return;
DoResourceCopy(resourcesPath, pass, ignoreSet, "", cancel);
});
return Task.CompletedTask;
}

Expand Down
Loading