From 87fa59b0f7b0ad1fa9ada8c28cd221fcdf1702ad Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 23 Aug 2012 15:29:17 -0400 Subject: [PATCH] Fix up version handling properly. Hopefully, and the error screen. --- .../cpw/mods/fml/client/FMLClientHandler.java | 4 +-- ...singGuiScreen.java => GuiModsMissing.java} | 7 ++--- fml/common/cpw/mods/fml/common/Loader.java | 29 ++++++++++++++----- .../mods/fml/common/MissingModsException.java | 1 - .../common/versioning/ArtifactVersion.java | 2 ++ .../versioning/DefaultArtifactVersion.java | 7 ++++- .../minecraft/src/GuiErrorScreen.java.patch | 13 +++++++++ 7 files changed, 47 insertions(+), 16 deletions(-) rename fml/client/cpw/mods/fml/client/{ModsMissingGuiScreen.java => GuiModsMissing.java} (84%) create mode 100644 fml/patches/minecraft/net/minecraft/src/GuiErrorScreen.java.patch diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index ec8105ef3..86068f948 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -184,9 +184,7 @@ public class FMLClientHandler implements IFMLSidedHandler { if (modsMissing != null) { - ModsMissingGuiScreen err = new ModsMissingGuiScreen(); - err.setList(modsMissing); - client.func_71373_a(err); + client.func_71373_a(new GuiModsMissing(modsMissing)); } else { diff --git a/fml/client/cpw/mods/fml/client/ModsMissingGuiScreen.java b/fml/client/cpw/mods/fml/client/GuiModsMissing.java similarity index 84% rename from fml/client/cpw/mods/fml/client/ModsMissingGuiScreen.java rename to fml/client/cpw/mods/fml/client/GuiModsMissing.java index b0f12d040..4937e7ba3 100644 --- a/fml/client/cpw/mods/fml/client/ModsMissingGuiScreen.java +++ b/fml/client/cpw/mods/fml/client/GuiModsMissing.java @@ -4,13 +4,12 @@ import cpw.mods.fml.common.MissingModsException; import cpw.mods.fml.common.versioning.ArtifactVersion; import net.minecraft.src.GuiErrorScreen; -public class ModsMissingGuiScreen extends GuiErrorScreen +public class GuiModsMissing extends GuiErrorScreen { private MissingModsException modsMissing; - - public void setList(MissingModsException modsMissing) + public GuiModsMissing(MissingModsException modsMissing) { this.modsMissing = modsMissing; } @@ -27,7 +26,7 @@ public class ModsMissingGuiScreen extends GuiErrorScreen for (ArtifactVersion v : modsMissing.missingMods) { offset+=10; - this.func_73732_a(this.field_73886_k, String.format("%s : %s", v.getLabel(), v.getVersionString()), this.field_73880_f / 2, offset, 0xEEEEEE); + this.func_73732_a(this.field_73886_k, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.field_73880_f / 2, offset, 0xEEEEEE); } offset+=20; this.func_73732_a(this.field_73886_k, "The file 'ForgeModLoader-client-0.log' contains more information", this.field_73880_f / 2, offset, 0xFFFFFF); diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index dfbd96453..d427a0c35 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -35,6 +35,7 @@ import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultiset; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -185,28 +186,39 @@ public class Loader for (ModContainer mod : getActiveModList()) { - Set missingMods = Sets.difference(mod.getRequirements(), modVersions.values()); + Map names = Maps.uniqueIndex(mod.getRequirements(), new Function() + { + public String apply(ArtifactVersion v) + { + return v.getLabel(); + } + }); + Set missingMods = Sets.difference(names.keySet(), modVersions.keySet()); + Set versionMissingMods = Sets.newHashSet(); if (!missingMods.isEmpty()) { FMLLog.severe("The mod %s (%s) requires mods %s to be available", mod.getModId(), mod.getName(), missingMods); - throw new MissingModsException(missingMods); + for (String modid : missingMods) + { + versionMissingMods.add(names.get(modid)); + } + throw new MissingModsException(versionMissingMods); } ImmutableList allDeps = ImmutableList.builder().addAll(mod.getDependants()).addAll(mod.getDependencies()).build(); for (ArtifactVersion v : allDeps) { - missingMods = Sets.newHashSet(); if (modVersions.containsKey(v.getLabel())) { if (!v.containsVersion(modVersions.get(v.getLabel()))) { - missingMods.add(v); + versionMissingMods.add(v); } } } - if (!missingMods.isEmpty()) + if (!versionMissingMods.isEmpty()) { FMLLog.severe("The mod %s (%s) requires mod versions %s to be available", mod.getModId(), mod.getName(), missingMods); - throw new MissingModsException(missingMods); + throw new MissingModsException(versionMissingMods); } } @@ -217,7 +229,10 @@ public class Loader try { FMLLog.fine("Sorting mods into an ordered list"); - mods = sorter.sort(); + List sortedMods = sorter.sort(); + mods.removeAll(sortedMods); + sortedMods.addAll(mods); + mods = sortedMods; FMLLog.fine("Mod sorting completed successfully"); } catch (ModSortingException sortException) diff --git a/fml/common/cpw/mods/fml/common/MissingModsException.java b/fml/common/cpw/mods/fml/common/MissingModsException.java index bd6170f95..b0d0cd221 100644 --- a/fml/common/cpw/mods/fml/common/MissingModsException.java +++ b/fml/common/cpw/mods/fml/common/MissingModsException.java @@ -15,5 +15,4 @@ public class MissingModsException extends RuntimeException { this.missingMods = missingMods; } - } diff --git a/fml/common/cpw/mods/fml/common/versioning/ArtifactVersion.java b/fml/common/cpw/mods/fml/common/versioning/ArtifactVersion.java index 8c9904fc3..52790a423 100644 --- a/fml/common/cpw/mods/fml/common/versioning/ArtifactVersion.java +++ b/fml/common/cpw/mods/fml/common/versioning/ArtifactVersion.java @@ -33,4 +33,6 @@ public interface ArtifactVersion String getVersionString(); boolean containsVersion(ArtifactVersion source); + + String getRangeString(); } diff --git a/fml/common/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java b/fml/common/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java index bcb10ad72..447b5a3e7 100644 --- a/fml/common/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java +++ b/fml/common/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java @@ -73,9 +73,14 @@ public class DefaultArtifactVersion implements ArtifactVersion @Override public String getVersionString() { - return comparableVersion==null ? "any" : comparableVersion.toString(); + return comparableVersion == null ? "unknown" : comparableVersion.toString(); } + @Override + public String getRangeString() + { + return range == null ? "any" : range.toString(); + } @Override public String toString() { diff --git a/fml/patches/minecraft/net/minecraft/src/GuiErrorScreen.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiErrorScreen.java.patch new file mode 100644 index 000000000..20b4c8905 --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/src/GuiErrorScreen.java.patch @@ -0,0 +1,13 @@ +--- ../src-base/minecraft/net/minecraft/src/GuiErrorScreen.java ++++ ../src-work/minecraft/net/minecraft/src/GuiErrorScreen.java +@@ -9,6 +9,10 @@ + private String field_74001_a; + private String field_74000_b; + ++ public GuiErrorScreen() ++ { ++ } ++ + public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_) + { + this.func_73733_a(0, 0, this.field_73880_f, this.field_73881_g, -12574688, -11530224);