diff options
| author | 2015-08-02 17:05:01 -0400 | |
|---|---|---|
| committer | 2015-08-02 17:05:01 -0400 | |
| commit | 7744d67e0416e1237c16bf0ddc0605eb5e7c1bb6 (patch) | |
| tree | 1d6fce572fef7e8b482e7b3a62ba75b32ab428e1 | |
| parent | fix up class matcher a bit (diff) | |
| download | enigma-fork-7744d67e0416e1237c16bf0ddc0605eb5e7c1bb6.tar.gz enigma-fork-7744d67e0416e1237c16bf0ddc0605eb5e7c1bb6.tar.xz enigma-fork-7744d67e0416e1237c16bf0ddc0605eb5e7c1bb6.zip | |
fix up converter some more
| -rw-r--r-- | src/cuchaz/enigma/ConvertMain.java | 15 | ||||
| -rw-r--r-- | src/cuchaz/enigma/convert/MappingsConverter.java | 44 |
2 files changed, 43 insertions, 16 deletions
diff --git a/src/cuchaz/enigma/ConvertMain.java b/src/cuchaz/enigma/ConvertMain.java index 068fe5b..1948c84 100644 --- a/src/cuchaz/enigma/ConvertMain.java +++ b/src/cuchaz/enigma/ConvertMain.java | |||
| @@ -44,19 +44,20 @@ public class ConvertMain { | |||
| 44 | // init files | 44 | // init files |
| 45 | String inVer = "1.8.3"; | 45 | String inVer = "1.8.3"; |
| 46 | String outVer = "1.8.8"; | 46 | String outVer = "1.8.8"; |
| 47 | String side = "client"; | ||
| 47 | File home = new File(System.getProperty("user.home")); | 48 | File home = new File(System.getProperty("user.home")); |
| 48 | JarFile sourceJar = new JarFile(new File(home, ".minecraft/versions/" + inVer + "/" + inVer + ".jar")); | 49 | JarFile sourceJar = new JarFile(new File(home, ".minecraft/versions/" + inVer + "/" + inVer + ".jar")); |
| 49 | JarFile destJar = new JarFile(new File(home, ".minecraft/versions/" + outVer + "/" + outVer + ".jar")); | 50 | JarFile destJar = new JarFile(new File(home, ".minecraft/versions/" + outVer + "/" + outVer + ".jar")); |
| 50 | File inMappingsFile = new File("../minecraft-mappings/" + inVer + ".mappings"); | 51 | File inMappingsFile = new File("../Enigma Mappings/" + inVer + "-" + side + ".mappings"); |
| 51 | File outMappingsFile = new File("../minecraft-mappings/" + outVer + ".mappings"); | 52 | File outMappingsFile = new File("../Enigma Mappings/" + outVer + "-" + side + ".mappings"); |
| 52 | Mappings mappings = new MappingsReader().read(new FileReader(inMappingsFile)); | 53 | Mappings mappings = new MappingsReader().read(new FileReader(inMappingsFile)); |
| 53 | File classMatchesFile = new File(inVer + "to" + outVer + ".class.matches"); | 54 | File classMatchesFile = new File(inVer + "to" + outVer + "-" + side + ".class.matches"); |
| 54 | File fieldMatchesFile = new File(inVer + "to" + outVer + ".field.matches"); | 55 | File fieldMatchesFile = new File(inVer + "to" + outVer + "-" + side + ".field.matches"); |
| 55 | File methodMatchesFile = new File(inVer + "to" + outVer + ".method.matches"); | 56 | File methodMatchesFile = new File(inVer + "to" + outVer + "-" + side + ".method.matches"); |
| 56 | 57 | ||
| 57 | // match classes | 58 | // match classes |
| 58 | //computeClassMatches(classMatchesFile, sourceJar, destJar, mappings); | 59 | //computeClassMatches(classMatchesFile, sourceJar, destJar, mappings); |
| 59 | editClasssMatches(classMatchesFile, sourceJar, destJar, mappings); | 60 | //editClasssMatches(classMatchesFile, sourceJar, destJar, mappings); |
| 60 | //convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile); | 61 | //convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile); |
| 61 | 62 | ||
| 62 | // match fields | 63 | // match fields |
| @@ -67,7 +68,7 @@ public class ConvertMain { | |||
| 67 | // match methods/constructors | 68 | // match methods/constructors |
| 68 | //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile); | 69 | //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile); |
| 69 | //editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile); | 70 | //editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile); |
| 70 | //convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile, methodMatchesFile); | 71 | convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile, methodMatchesFile); |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings) | 74 | private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings) |
diff --git a/src/cuchaz/enigma/convert/MappingsConverter.java b/src/cuchaz/enigma/convert/MappingsConverter.java index b404e8f..958a17c 100644 --- a/src/cuchaz/enigma/convert/MappingsConverter.java +++ b/src/cuchaz/enigma/convert/MappingsConverter.java | |||
| @@ -27,6 +27,7 @@ import com.google.common.collect.Maps; | |||
| 27 | import com.google.common.collect.Multimap; | 27 | import com.google.common.collect.Multimap; |
| 28 | import com.google.common.collect.Sets; | 28 | import com.google.common.collect.Sets; |
| 29 | 29 | ||
| 30 | import cuchaz.enigma.Constants; | ||
| 30 | import cuchaz.enigma.Deobfuscator; | 31 | import cuchaz.enigma.Deobfuscator; |
| 31 | import cuchaz.enigma.analysis.JarIndex; | 32 | import cuchaz.enigma.analysis.JarIndex; |
| 32 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; | 33 | import cuchaz.enigma.convert.ClassNamer.SidedClassNamer; |
| @@ -208,33 +209,58 @@ public class MappingsConverter { | |||
| 208 | } | 209 | } |
| 209 | 210 | ||
| 210 | // migrate fields | 211 | // migrate fields |
| 211 | for (FieldMapping fieldMapping : oldClassMapping.fields()) { | 212 | for (FieldMapping oldFieldMapping : oldClassMapping.fields()) { |
| 212 | if (canMigrate(fieldMapping.getObfType(), replacer)) { | 213 | if (canMigrate(oldFieldMapping.getObfType(), matches)) { |
| 213 | newClassMapping.addFieldMapping(new FieldMapping(fieldMapping, replacer)); | 214 | newClassMapping.addFieldMapping(new FieldMapping(oldFieldMapping, replacer)); |
| 215 | } else { | ||
| 216 | System.out.println(String.format("Can't map field, dropping: %s.%s %s", | ||
| 217 | oldClassMapping.getDeobfName(), | ||
| 218 | oldFieldMapping.getDeobfName(), | ||
| 219 | oldFieldMapping.getObfType() | ||
| 220 | )); | ||
| 214 | } | 221 | } |
| 215 | } | 222 | } |
| 216 | 223 | ||
| 217 | // migrate methods | 224 | // migrate methods |
| 218 | for (MethodMapping oldMethodMapping : oldClassMapping.methods()) { | 225 | for (MethodMapping oldMethodMapping : oldClassMapping.methods()) { |
| 219 | if (canMigrate(oldMethodMapping.getObfSignature(), replacer)) { | 226 | if (canMigrate(oldMethodMapping.getObfSignature(), matches)) { |
| 220 | newClassMapping.addMethodMapping(new MethodMapping(oldMethodMapping, replacer)); | 227 | newClassMapping.addMethodMapping(new MethodMapping(oldMethodMapping, replacer)); |
| 228 | } else { | ||
| 229 | System.out.println(String.format("Can't map method, dropping: %s.%s %s", | ||
| 230 | oldClassMapping.getDeobfName(), | ||
| 231 | oldMethodMapping.getDeobfName(), | ||
| 232 | oldMethodMapping.getObfSignature() | ||
| 233 | )); | ||
| 221 | } | 234 | } |
| 222 | } | 235 | } |
| 223 | 236 | ||
| 224 | return newClassMapping; | 237 | return newClassMapping; |
| 225 | } | 238 | } |
| 226 | 239 | ||
| 227 | private static boolean canMigrate(Signature obfSignature, ClassNameReplacer replacer) { | 240 | private static boolean canMigrate(Signature oldObfSignature, ClassMatches classMatches) { |
| 228 | for (Type type : obfSignature.types()) { | 241 | for (Type oldObfType : oldObfSignature.types()) { |
| 229 | if (!canMigrate(type, replacer)) { | 242 | if (!canMigrate(oldObfType, classMatches)) { |
| 230 | return false; | 243 | return false; |
| 231 | } | 244 | } |
| 232 | } | 245 | } |
| 233 | return true; | 246 | return true; |
| 234 | } | 247 | } |
| 235 | 248 | ||
| 236 | private static boolean canMigrate(Type type, ClassNameReplacer replacer) { | 249 | private static boolean canMigrate(Type oldObfType, ClassMatches classMatches) { |
| 237 | return !type.hasClass() || replacer.replace(type.getClassEntry().getClassName()) != null; | 250 | |
| 251 | // non classes can be migrated | ||
| 252 | if (!oldObfType.hasClass()) { | ||
| 253 | return true; | ||
| 254 | } | ||
| 255 | |||
| 256 | // non obfuscated classes can be migrated | ||
| 257 | ClassEntry classEntry = oldObfType.getClassEntry(); | ||
| 258 | if (!classEntry.getPackageName().equals(Constants.NonePackage)) { | ||
| 259 | return true; | ||
| 260 | } | ||
| 261 | |||
| 262 | // obfuscated classes with mappings can be migrated | ||
| 263 | return classMatches.getUniqueMatches().containsKey(classEntry); | ||
| 238 | } | 264 | } |
| 239 | 265 | ||
| 240 | public static void convertMappings(Mappings mappings, BiMap<ClassEntry,ClassEntry> changes) { | 266 | public static void convertMappings(Mappings mappings, BiMap<ClassEntry,ClassEntry> changes) { |