Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix capitalization check for zipped shaders #2457

Merged
Merged
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
4 changes: 3 additions & 1 deletion common/src/main/java/net/irisshaders/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ private static boolean loadExternalShaderpack(String name) {
}

Path shaderPackPath;
boolean isZip = false;

if (!Files.isDirectory(shaderPackRoot) && shaderPackRoot.toString().endsWith(".zip")) {
Optional<Path> optionalPath;
Expand Down Expand Up @@ -281,6 +282,7 @@ private static boolean loadExternalShaderpack(String name) {
logger.error("Could not load the shaderpack \"{}\" because it appears to lack a \"shaders\" directory", name);
return false;
}
isZip = true;
} else {
if (!Files.exists(shaderPackRoot)) {
logger.error("Failed to load the shaderpack \"{}\" because it does not exist!", name);
Expand Down Expand Up @@ -309,7 +311,7 @@ private static boolean loadExternalShaderpack(String name) {
resetShaderPackOptions = false;

try {
currentPack = new ShaderPack(shaderPackPath, changedConfigs, StandardMacros.createStandardEnvironmentDefines());
currentPack = new ShaderPack(shaderPackPath, changedConfigs, StandardMacros.createStandardEnvironmentDefines(), isZip);

MutableOptionValues changedConfigsValues = currentPack.getShaderPackOptions().getOptionValues().mutableCopy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public class ShaderPack {
private final List<String> dimensionIds;
private Map<NamespacedId, String> dimensionMap;

public ShaderPack(Path root, ImmutableList<StringPair> environmentDefines) throws IOException, IllegalStateException {
this(root, Collections.emptyMap(), environmentDefines);
public ShaderPack(Path root, ImmutableList<StringPair> environmentDefines, boolean isZip) throws IOException, IllegalStateException {
this(root, Collections.emptyMap(), environmentDefines, isZip);
}

/**
Expand All @@ -99,7 +99,7 @@ public ShaderPack(Path root, ImmutableList<StringPair> environmentDefines) throw
* have completed, and there is no need to hold on to the path for that reason.
* @throws IOException if there are any IO errors during shader pack loading.
*/
public ShaderPack(Path root, Map<String, String> changedConfigs, ImmutableList<StringPair> environmentDefines) throws IOException, IllegalStateException {
public ShaderPack(Path root, Map<String, String> changedConfigs, ImmutableList<StringPair> environmentDefines, boolean isZip) throws IOException, IllegalStateException {
// A null path is not allowed.
Objects.requireNonNull(root);

Expand Down Expand Up @@ -149,7 +149,7 @@ public ShaderPack(Path root, Map<String, String> changedConfigs, ImmutableList<S
}

// Read all files and included files recursively
IncludeGraph graph = new IncludeGraph(root, starts.build());
IncludeGraph graph = new IncludeGraph(root, starts.build(), isZip);

if (!graph.getFailures().isEmpty()) {
throw new IOException(String.join("\n", graph.getFailures().values().stream().map(RusticError::toString).toArray(String[]::new)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private IncludeGraph(ImmutableMap<AbsolutePackPath, FileNode> nodes,
this.failures = failures;
}

public IncludeGraph(Path root, ImmutableList<AbsolutePackPath> startingPaths) {
public IncludeGraph(Path root, ImmutableList<AbsolutePackPath> startingPaths, boolean isZip) {
Map<AbsolutePackPath, AbsolutePackPath> cameFrom = new HashMap<>();
Map<AbsolutePackPath, Integer> lineNumberInclude = new HashMap<>();

Expand All @@ -81,9 +81,15 @@ public IncludeGraph(Path root, ImmutableList<AbsolutePackPath> startingPaths) {

try {
Path p = next.resolved(root);
if (Iris.getIrisConfig().areDebugOptionsEnabled() && root.isAbsolute() && !p.toAbsolutePath().toString().equals(p.toFile().getCanonicalPath())) {
throw new FileIncludeException("'" + next.getPathString() + "' doesn't exist, did you mean '" +
root.relativize(p.toFile().getCanonicalFile().toPath()).toString().replace("\\", "/") + "'?");
if (Iris.getIrisConfig().areDebugOptionsEnabled() && !isZip) {
String absolute = p.toAbsolutePath().toString().replace("\\", "/");
absolute = absolute.substring(absolute.lastIndexOf("shaders/") + 8);

String canonical = p.toFile().getCanonicalPath().replace("\\", "/");
canonical = canonical.substring(canonical.lastIndexOf("shaders/") + 8);
if (!absolute.equals(canonical)) {
throw new FileIncludeException("'" + next.getPathString() + "' doesn't exist, did you mean '" + canonical + "'?");
}
}
source = readFile(p);
} catch (IOException e) {
Expand Down
Loading