Skip to content

Commit

Permalink
fix: shader references (cloneshader etc) not including their resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ovska committed Oct 24, 2024
1 parent 211e3aa commit 798a852
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
4 changes: 4 additions & 0 deletions Pack3r.Console/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"sungilarity src": {
"commandName": "Project",
"commandLineArgs": "\"C:\\Temp\\ET\\map\\ET\\etmain\\maps\\sungilarity.map\" -d -i -s -rd -m etjump_stable"
},
"unsung": {
"commandName": "Project",
"commandLineArgs": "\"C:\\Temp\\ET\\map\\ET\\etmain\\maps\\unsung.map\" -d -m etjump_stable"
}
}
}
66 changes: 38 additions & 28 deletions Pack3r.Core/Services/Packager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,44 +100,54 @@ public async Task<PackResult> CreateZip(
if (shaderName.Equals("noshader"))
continue;

// already handled
if (!handledShaders.Add(shaderName))
continue;
HandleShaderRecursive(shaderName);

if (!shadersByName.TryGetValue(shaderName, out Shader? shader))
void HandleShaderRecursive(QPath shaderName)
{
// might just be a texture without a shader
AddFileRelative(shaderName, shaderResource);
continue;
}
// already handled
if (!handledShaders.Add(shaderName))
return;

styleLights = styleLights || shader.HasLightStyles;
if (!shadersByName.TryGetValue(shaderName, out Shader? shader))
{
// might just be a texture without a shader
AddFileRelative(shaderName, shaderResource);
return;
}

if (!shader.NeededInPk3)
continue;
styleLights = styleLights || shader.HasLightStyles;

if (!handledFiles.Contains(shader.DestinationPath.AsMemory()))
AddShaderFile(shader, shaderResource);
if (!shader.NeededInPk3)
return;

if (shader.ImplicitMapping is { } implicitMapping)
{
AddFileRelative(implicitMapping, shaderResource, shader);
}
if (!handledFiles.Contains(shader.DestinationPath.AsMemory()))
AddShaderFile(shader, shaderResource);

foreach (var file in shader.Resources)
{
if (IsHandledOrExcluded(file))
continue;
if (shader.ImplicitMapping is { } implicitMapping)
{
AddFileRelative(implicitMapping, shaderResource, shader);
}

AddFileRelative(file, shaderResource, shader);
}
foreach (var file in shader.Resources)
{
if (IsHandledOrExcluded(file))
continue;

foreach (var file in shader.DevResources)
{
if (IsHandledOrExcluded(file))
continue;
AddFileRelative(file, shaderResource, shader);
}

foreach (var file in shader.DevResources)
{
if (IsHandledOrExcluded(file))
continue;

AddFileRelative(file, shaderResource, shader, devResource: true);
}

AddFileRelative(file, shaderResource, shader, devResource: true);
foreach (var inner in shader.Shaders)
{
HandleShaderRecursive(inner);
}
}
}
}
Expand Down

0 comments on commit 798a852

Please sign in to comment.