diff --git a/fml/build.xml b/fml/build.xml index 23f81ea59..9de1b4567 100644 --- a/fml/build.xml +++ b/fml/build.xml @@ -151,7 +151,7 @@ - + @@ -382,22 +382,22 @@ - - + + - - + + diff --git a/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java b/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java index bf3c58072..2fee95497 100644 --- a/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java +++ b/fml/common/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java @@ -41,6 +41,7 @@ import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; @@ -415,4 +416,9 @@ public class FMLDeobfuscatingRemapper extends Remapper { fieldNameMaps.put(name, ImmutableMap.copyOf(fieldMap)); // System.out.printf("Maps: %s %s\n", name, methodMap); } + + public Set getObfedClasses() + { + return ImmutableSet.copyOf(classNameBiMap.keySet()); + } } diff --git a/fml/common/cpw/mods/fml/common/patcher/GenDiffSet.java b/fml/common/cpw/mods/fml/common/patcher/GenDiffSet.java index b5e6cd3a7..96dcd6516 100644 --- a/fml/common/cpw/mods/fml/common/patcher/GenDiffSet.java +++ b/fml/common/cpw/mods/fml/common/patcher/GenDiffSet.java @@ -8,8 +8,6 @@ import java.util.jar.JarFile; import java.util.logging.Level; import java.util.logging.Logger; -import org.omg.CORBA.REBIND; - import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; import com.google.common.io.ByteArrayDataOutput; @@ -23,35 +21,34 @@ public class GenDiffSet { public static void main(String[] args) throws IOException { - String vanillaMinecraftJar = args[0]; - String targetJar = args[1]; - String reobfuscationOutputPath = args[2]; - String deobfFileName = args[3]; - String binPatchOutputDir = args[4]; + String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar + String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft + String deobfData = args[2]; //Path to FML's deobfusication_data.zip + String outputDir = args[3]; //Path to place generated .binpatch + String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch - Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", binPatchOutputDir, targetJar, reobfuscationOutputPath)); + Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir)); Delta delta = new Delta(); FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE; - remapper.setupLoadOnly(deobfFileName, false); - JarFile originalJarFile = new JarFile(vanillaMinecraftJar); - JarFile targetJarFile = new JarFile(targetJar); + remapper.setupLoadOnly(deobfData, false); + JarFile sourceZip = new JarFile(sourceJar); + boolean kill = killTarget.equalsIgnoreCase("true"); - File f = new File(binPatchOutputDir); + File f = new File(outputDir); f.mkdirs(); - for (JarEntry e : Collections.list(originalJarFile.entries())) + for (String name : remapper.getObfedClasses()) { - String name = e.getName(); // Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name)); - File reobfOutput = new File(reobfuscationOutputPath, name); - if (reobfOutput.exists()) + File targetFile = new File(targetDir, name.replace('/', File.separatorChar) + ".class"); + if (targetFile.exists()) { - String sourceClassName = name.substring(0, name.lastIndexOf(".")).replace('/', '.'); - String targetClassName = remapper.map(name.substring(0,name.lastIndexOf("."))).replace('/', '.'); - JarEntry entry = targetJarFile.getJarEntry(name); + String sourceClassName = name.replace('/', '.'); + String targetClassName = remapper.map(name).replace('/', '.'); + JarEntry entry = sourceZip.getJarEntry(name); - byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(targetJarFile.getInputStream(entry)) : new byte[0]; - byte[] patchedBytes = Files.toByteArray(reobfOutput); + byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0]; + byte[] patchedBytes = Files.toByteArray(targetFile); byte[] diff = delta.compute(vanillaBytes, patchedBytes); @@ -63,18 +60,24 @@ public class GenDiffSet { // Target name diffOut.writeUTF(targetClassName); // exists at original - diffOut.writeBoolean(entry!=null); + diffOut.writeBoolean(entry != null); // length of patch diffOut.writeInt(diff.length); // patch diffOut.write(diff); - File target = new File(binPatchOutputDir, targetClassName+".binpatch"); + File target = new File(outputDir, targetClassName+".binpatch"); target.getParentFile().mkdirs(); Files.write(diffOut.toByteArray(), target); Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath())); + if (kill) + { + targetFile.delete(); + Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString())); + } } } + sourceZip.close(); } }