mirror of
https://github.com/codestation/mhtools
synced 2024-11-10 05:44:17 +00:00
Added support for data install in the creation of patchfiles
This commit is contained in:
parent
c04918cffe
commit
2f84945b33
3 changed files with 85 additions and 0 deletions
2
README
2
README
|
@ -38,3 +38,5 @@ java -jar mhtrans.jar --gen-index /home/user/data.bin
|
|||
|
||||
To create a patchfile, e.g.:
|
||||
java -jar mhtrans.jar --create-patch 0017.bin.enc 2813.bin.enc 2814.bin.enc MHP3RD_DATA.BIN
|
||||
(Note, it can use an optional data_install.txt to create tables that can be used in
|
||||
patchers who can patch the data install)
|
||||
|
|
19
data_install.txt
Normal file
19
data_install.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
# translation_file, data_install_file, offset in the data install file where translation_file is found
|
||||
0017,0011,00204000
|
||||
2813,0031,00280800
|
||||
2814,0031,00284800
|
||||
2816,0031,002AE000
|
||||
2817,0031,002D1800
|
||||
2818,0031,00331000
|
||||
3973,0032,0033F800
|
||||
3974,0032,00341800
|
||||
3975,0032,00346000
|
||||
3976,0032,0034B800
|
||||
3977,0032,00351000
|
||||
3978,0032,00356800
|
||||
3979,0032,0035C000
|
||||
3980,0032,00361000
|
||||
3984,0032,00367000
|
||||
3985,0032,00369000
|
||||
3986,0033,00000000
|
||||
3987,0033,00001000
|
|
@ -1,15 +1,19 @@
|
|||
package base;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import crypt.DecryptTable;
|
||||
|
||||
|
@ -47,6 +51,7 @@ public class PatchBuilder extends DecryptTable {
|
|||
out.seek(current);
|
||||
}
|
||||
writeInt(out, 0);
|
||||
install_tables(out, list);
|
||||
out.close();
|
||||
}catch(FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -57,6 +62,65 @@ public class PatchBuilder extends DecryptTable {
|
|||
}
|
||||
}
|
||||
|
||||
private void install_tables(RandomAccessFile out, List<String> list) {
|
||||
System.out.print("Trying to add data_install tables...");
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new FileReader("data_install.txt"));
|
||||
out.seek(out.length());
|
||||
|
||||
String line;
|
||||
Vector<Integer> patch_files = new Vector<Integer>();
|
||||
Vector<String> install_files = new Vector<String>();
|
||||
Vector<String> offsets = new Vector<String>();
|
||||
|
||||
while((line = in.readLine()) != null) {
|
||||
if(!line.startsWith("#")) {
|
||||
String []tokens = line.split(",");
|
||||
patch_files.add(Integer.parseInt(tokens[0]));
|
||||
install_files.add(tokens[1]);
|
||||
offsets.add(tokens[2]);
|
||||
}
|
||||
}
|
||||
Vector<String> install_uniq = new Vector<String>(new LinkedHashSet<String>(install_files));
|
||||
writeInt(out, install_uniq.size());
|
||||
int install_count = 0;
|
||||
String match = install_files.firstElement();
|
||||
out.write(match.getBytes());
|
||||
writeInt(out, install_count);
|
||||
for(String file : install_files) {
|
||||
if(!match.equals(file)) {
|
||||
out.write(file.getBytes());
|
||||
match = file;
|
||||
writeInt(out, install_count);
|
||||
}
|
||||
install_count++;
|
||||
}
|
||||
for(String trans_file : list) {
|
||||
int index = patch_files.indexOf(extractNumber(trans_file));
|
||||
int offset = -1;
|
||||
if(index != -1) {
|
||||
// UGH!!, 11 years and the Integer.parseInt bug isn't fixed
|
||||
// This is the last time that i use Java in a project of mine
|
||||
// http://bugs.sun.com/view_bug.do?bug_id=4215269
|
||||
offset = (int)Long.parseLong(offsets.get(index),16);
|
||||
} else {
|
||||
System.out.println("Install info not found for " + trans_file);
|
||||
}
|
||||
writeInt(out, offset);
|
||||
}
|
||||
long filelength = out.length();
|
||||
if(filelength % 16 > 0) {
|
||||
filelength += 16 - (filelength % 16);
|
||||
out.setLength(filelength);
|
||||
}
|
||||
System.out.println("OK");
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("\ndata_install.txt not found");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The "writeInt" function of java writes in BigEndian mode but we need
|
||||
* LittleEndian so i made a custom function for that
|
||||
|
|
Loading…
Reference in a new issue