summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/ConvertMain.java
diff options
context:
space:
mode:
authorGravatar jeff2015-03-13 16:46:02 -0400
committerGravatar jeff2015-03-13 16:46:02 -0400
commit65f551cd25739f1ccfa15d819c6a23060ebf2629 (patch)
treefd0cb0da21787fe77ea502560e023a03600e58dc /src/cuchaz/enigma/ConvertMain.java
parentworking on writing mappings based on all the matches (diff)
downloadenigma-fork-65f551cd25739f1ccfa15d819c6a23060ebf2629.tar.gz
enigma-fork-65f551cd25739f1ccfa15d819c6a23060ebf2629.tar.xz
enigma-fork-65f551cd25739f1ccfa15d819c6a23060ebf2629.zip
complete mappings converion code. Still need to debug though
Diffstat (limited to 'src/cuchaz/enigma/ConvertMain.java')
-rw-r--r--src/cuchaz/enigma/ConvertMain.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/cuchaz/enigma/ConvertMain.java b/src/cuchaz/enigma/ConvertMain.java
index 15658d9..c5c92bc 100644
--- a/src/cuchaz/enigma/ConvertMain.java
+++ b/src/cuchaz/enigma/ConvertMain.java
@@ -46,13 +46,12 @@ public class ConvertMain {
46 // match fields 46 // match fields
47 //computeFieldMatches(fieldMatchesFile, destJar, outMappingsFile, classMatchesFile); 47 //computeFieldMatches(fieldMatchesFile, destJar, outMappingsFile, classMatchesFile);
48 //editFieldMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, fieldMatchesFile); 48 //editFieldMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, fieldMatchesFile);
49 //convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile);
49 50
50 // match methods/constructors 51 // match methods/constructors
51 //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile); 52 //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile);
52 //editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile); 53 //editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile);
53 54 convertMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile, methodMatchesFile);
54 // write final converted mappings
55 writeFinalMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile, methodMatchesFile);
56 } 55 }
57 56
58 private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings) 57 private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings)
@@ -146,6 +145,28 @@ public class ConvertMain {
146 } 145 }
147 }); 146 });
148 } 147 }
148
149 private static void convertMappings(File outMappingsFile, JarFile sourceJar, JarFile destJar, Mappings mappings, File classMatchesFile, File fieldMatchesFile)
150 throws IOException {
151
152 System.out.println("Reading matches...");
153 ClassMatches classMatches = MatchesReader.readClasses(classMatchesFile);
154 MemberMatches<FieldEntry> fieldMatches = MatchesReader.readMembers(fieldMatchesFile);
155
156 Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar);
157 deobfuscators.source.setMappings(mappings);
158
159 // apply matches
160 Mappings newMappings = MappingsConverter.newMappings(classMatches, mappings, deobfuscators.source, deobfuscators.dest);
161 MappingsConverter.applyMemberMatches(newMappings, fieldMatches, MappingsConverter.getFieldDoer());
162
163 // write out the converted mappings
164 try (FileWriter out = new FileWriter(outMappingsFile)) {
165 new MappingsWriter().write(out, newMappings);
166 }
167 System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath());
168 }
169
149 170
150 private static void computeMethodMatches(File methodMatchesFile, JarFile destJar, File destMappingsFile, File classMatchesFile) 171 private static void computeMethodMatches(File methodMatchesFile, JarFile destJar, File destMappingsFile, File classMatchesFile)
151 throws IOException, MappingParseException { 172 throws IOException, MappingParseException {
@@ -198,7 +219,7 @@ public class ConvertMain {
198 }); 219 });
199 } 220 }
200 221
201 private static void writeFinalMappings(File outMappingsFile, JarFile sourceJar, JarFile destJar, Mappings mappings, File classMatchesFile, File fieldMatchesFile, File methodMatchesFile) 222 private static void convertMappings(File outMappingsFile, JarFile sourceJar, JarFile destJar, Mappings mappings, File classMatchesFile, File fieldMatchesFile, File methodMatchesFile)
202 throws IOException { 223 throws IOException {
203 224
204 System.out.println("Reading matches..."); 225 System.out.println("Reading matches...");