Skip to content

Commit

Permalink
Include the list of options and rules when the solver system returns …
Browse files Browse the repository at this point in the history
…duplicate mods after solving.
  • Loading branch information
AlexIIL committed Aug 24, 2024
1 parent 9661e47 commit 02c2a66
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ group = org.quiltmc
description = The mod loading component of Quilt
url = https://github.com/quiltmc/quilt-loader
# Don't forget to change this in QuiltLoaderImpl as well
quilt_loader = 0.26.4-beta.2
quilt_loader = 0.26.4-beta.3

# Fabric & Quilt Libraries
asm = 9.6
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/quiltmc/loader/impl/QuiltLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public final class QuiltLoaderImpl {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.26.4-beta.2";
public static final String VERSION = "0.26.4-beta.3";
public static final String MOD_ID = "quilt_loader";
public static final String DEFAULT_MODS_DIR = "mods";
public static final String DEFAULT_CACHE_DIR = ".cache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1590,24 +1590,37 @@ ModSolveResultImpl getPartialSolution() throws ModSolvingError, TimeoutException
Map<Class<?>, LoadOptionResult<?>> extraResults;
final Map<Class<?>, Map<Object, Boolean>> optionMap = new HashMap<>();

for (LoadOption option : solution) {
try {
for (LoadOption option : solution) {

boolean load = true;
if (LoadOption.isNegated(option)) {
option = option.negate();
load = false;
}
boolean load = true;
if (LoadOption.isNegated(option)) {
option = option.negate();
load = false;
}

if (load && option instanceof ModLoadOption) {
ModLoadOption mod = (ModLoadOption) option;
putMod(directModsMap, mod.id(), mod);
if (load && option instanceof ModLoadOption) {
ModLoadOption mod = (ModLoadOption) option;
putMod(directModsMap, mod.id(), mod);

for (ProvidedMod provided : mod.metadata().provides()) {
putMod(providedModsMap, provided.id(), mod);
for (ProvidedMod provided : mod.metadata().provides()) {
putMod(providedModsMap, provided.id(), mod);
}
}
}

putHierarchy(option, load, optionMap);
putHierarchy(option, load, optionMap);
}
} catch (ModSolvingError cause) {
// Something went wrong during solving
StringBuilder errorDesc = new StringBuilder("The solver returned a solution with duplicate mods!\n");
errorDesc.append(cause.getMessage());
errorDesc.append("\n\nCurrent Solution:");
for (LoadOption option : solution) {
errorDesc.append("\n\t-" + option);
}
errorDesc.append("\n\n");
solver.appendRules(errorDesc);
throw new ModSolvingError(errorDesc.toString(), cause);
}

extraResults = new HashMap<>();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/quiltmc/loader/impl/solver/Sat4jWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ public void cancel() {
cancelled = true;
}

// #############
// # Debugging #
// #############

/** Appends all current rules and options using the {@link SolverPreProcessor} format. */
public void appendRules(StringBuilder sb) {
InputRuleSet ruleSet = new InputRuleSet(optionToWeight, ruleToDefinitions);
SolverPreProcessor.appendRuleSet(ruleSet, ruleSet, str -> sb.append("\n" + str));
}

// ############
// # Internal #
// ############
Expand Down

0 comments on commit 02c2a66

Please sign in to comment.