mirror of
https://github.com/Maschell/JNUSLib.git
synced 2024-11-26 09:54:18 +01:00
Fixed file offset calculation.
This commit is contained in:
parent
82a3d5253c
commit
e8236e86d2
@ -34,13 +34,13 @@ import lombok.Getter;
|
|||||||
public final class FST {
|
public final class FST {
|
||||||
@Getter private final FSTEntry root = FSTEntry.getRootFSTEntry();
|
@Getter private final FSTEntry root = FSTEntry.getRootFSTEntry();
|
||||||
|
|
||||||
@Getter private final int unknown;
|
@Getter private final int sectorSize;
|
||||||
@Getter private final int contentCount;
|
@Getter private final int contentCount;
|
||||||
|
|
||||||
@Getter private final Map<Integer, ContentFSTInfo> contentFSTInfos = new HashMap<>();
|
@Getter private final Map<Integer, ContentFSTInfo> contentFSTInfos = new HashMap<>();
|
||||||
|
|
||||||
private FST(int unknown, int contentCount) {
|
private FST(int unknown, int contentCount) {
|
||||||
this.unknown = unknown;
|
this.sectorSize = unknown;
|
||||||
this.contentCount = contentCount;
|
this.contentCount = contentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +55,15 @@ public final class FST {
|
|||||||
*/
|
*/
|
||||||
public static FST parseFST(byte[] fstData, Map<Integer, Content> contentsMappedByIndex) {
|
public static FST parseFST(byte[] fstData, Map<Integer, Content> contentsMappedByIndex) {
|
||||||
if (!Arrays.equals(Arrays.copyOfRange(fstData, 0, 3), new byte[] { 0x46, 0x53, 0x54 })) {
|
if (!Arrays.equals(Arrays.copyOfRange(fstData, 0, 3), new byte[] { 0x46, 0x53, 0x54 })) {
|
||||||
throw new NullPointerException();
|
throw new RuntimeException("Failed to parse FST");
|
||||||
// return null;
|
// return null;
|
||||||
// throw new IllegalArgumentException("Not a FST. Maybe a wrong key?");
|
// throw new IllegalArgumentException("Not a FST. Maybe a wrong key?");
|
||||||
}
|
}
|
||||||
|
|
||||||
int unknownValue = ByteUtils.getIntFromBytes(fstData, 0x04);
|
int sectorSize = ByteUtils.getIntFromBytes(fstData, 0x04);
|
||||||
int contentCount = ByteUtils.getIntFromBytes(fstData, 0x08);
|
int contentCount = ByteUtils.getIntFromBytes(fstData, 0x08);
|
||||||
|
|
||||||
FST result = new FST(unknownValue, contentCount);
|
FST result = new FST(sectorSize, contentCount);
|
||||||
|
|
||||||
int contentfst_offset = 0x20;
|
int contentfst_offset = 0x20;
|
||||||
int contentfst_size = 0x20 * contentCount;
|
int contentfst_size = 0x20 * contentCount;
|
||||||
@ -94,7 +94,7 @@ public final class FST {
|
|||||||
|
|
||||||
FSTEntry root = result.getRoot();
|
FSTEntry root = result.getRoot();
|
||||||
|
|
||||||
FSTService.parseFST(root, fstSection, nameSection, contentsMappedByIndex, contentFSTInfos);
|
FSTService.parseFST(root, fstSection, nameSection, contentsMappedByIndex, contentFSTInfos, sectorSize);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public final class FSTService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void parseFST(FSTEntry rootEntry, byte[] fstSection, byte[] namesSection, Map<Integer, Content> contentsByIndex,
|
public static void parseFST(FSTEntry rootEntry, byte[] fstSection, byte[] namesSection, Map<Integer, Content> contentsByIndex,
|
||||||
Map<Integer, ContentFSTInfo> contentsFSTByIndex) {
|
Map<Integer, ContentFSTInfo> contentsFSTByIndex, int sectorSize) {
|
||||||
int totalEntries = ByteUtils.getIntFromBytes(fstSection, 0x08);
|
int totalEntries = ByteUtils.getIntFromBytes(fstSection, 0x08);
|
||||||
|
|
||||||
int level = 0;
|
int level = 0;
|
||||||
@ -99,7 +99,7 @@ public final class FSTService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entryParam.setFileOffset(fileOffset << 5);
|
entryParam.setFileOffset(fileOffset * sectorSize);
|
||||||
|
|
||||||
entryParam.setFileSize(fileSize);
|
entryParam.setFileSize(fileSize);
|
||||||
parent = fstEntryToOffsetMap.get(Entry[level - 1]);
|
parent = fstEntryToOffsetMap.get(Entry[level - 1]);
|
||||||
@ -114,11 +114,6 @@ public final class FSTService {
|
|||||||
if (content == null) {
|
if (content == null) {
|
||||||
log.warning("Content for FST Entry not found");
|
log.warning("Content for FST Entry not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (content.isHashed() && (content.getDecryptedFileSize() < (fileOffset << 5))) { // TODO: Figure out how this works...
|
|
||||||
entryParam.setFileOffset(fileOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
entryParam.setContent(content);
|
entryParam.setContent(content);
|
||||||
|
|
||||||
ContentFSTInfo contentFSTInfo = contentsFSTByIndex.get((int) contentIndex);
|
ContentFSTInfo contentFSTInfo = contentsFSTByIndex.get((int) contentIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user