Skip to content

Commit

Permalink
Merge pull request #17 from Displee/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Displee authored Apr 13, 2019
2 parents 6c2358b + f255d8f commit fde8e1e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 26 deletions.
Binary file modified RS2-Cache-Library.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main/java/org/displee/cache/index/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public boolean writeArchiveSector(int id, byte[] data) {
while (written < data.length) {
int currentPosition = 0;
if (overWrite) {
super.origin.getMainFile().seek(position * Constants.ARCHIVE_SIZE);
super.origin.getMainFile().seek((long) position * Constants.ARCHIVE_SIZE);
super.origin.getMainFile().read(buffer, 0, archiveHeaderSize);
archiveSector.read(new InputStream(buffer));
currentPosition = archiveSector.getNextPosition();
Expand Down Expand Up @@ -314,7 +314,7 @@ public boolean writeArchiveSector(int id, byte[] data) {
archiveSector.setType(archiveDataSize == 510 ? 1 : 0);
archiveSector.setChunk(chunk);
archiveSector.setPosition(currentPosition);
super.origin.getMainFile().seek(position * Constants.ARCHIVE_SIZE);
super.origin.getMainFile().seek((long) position * Constants.ARCHIVE_SIZE);
archiveSector.write(new OutputStream(archiveHeaderSize));
super.origin.getMainFile().write(archiveSector.write(new OutputStream(archiveHeaderSize)), 0, archiveHeaderSize);
int length = data.length - written;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/displee/cache/index/Index317.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public Archive getArchive(int id, int[] xtea, boolean direct) {
}
for (final Archive archive : archives) {
if (archive.getId() == id) {
if (direct || archive.isRead()) {
if (direct || archive.isRead() || archive.isNew()) {
return archive;
}
final ArchiveSector archiveSector = origin.getIndex(this.id).readArchiveSector(id);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/displee/cache/index/ReferenceTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public Archive getArchive(int id, int[] xtea, boolean direct) {
}
for (final Archive archive : archives) {
if (archive.getId() == id) {
if (direct || archive.isRead()) {
if (direct || archive.isRead() || archive.isNew()) {
return archive;
}
final ArchiveSector archiveSector = origin.getIndex(this.id).readArchiveSector(id);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/displee/cache/index/archive/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public void restore() {
file.setData(null);
}
read = false;
isNew = false;
}

/**
Expand Down
24 changes: 2 additions & 22 deletions src/test/java/Test.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import org.displee.CacheLibrary;
import org.displee.CacheLibraryMode;
import org.displee.cache.index.Index;
import org.displee.cache.index.archive.Archive;
import org.displee.cache.index.archive.Archive317;
import org.displee.io.impl.InputStream;
import org.displee.io.impl.OutputStream;
import org.displee.utilities.GZIPCompressor;
import org.displee.utilities.HashGenerator;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

public class Test {

public static void main(String[] args) throws Exception {
test1();
//System.out.println("");
//test2();
}

//0 = config, models = 1, animation = 2, midi = 3, maps = 4
private static void test1() throws Exception {
CacheLibrary cache = new CacheLibrary("C:\\Users\\Maffia\\RuthlessPSCache", CacheLibraryMode.UN_CACHED);
Index index = cache.getIndex(7);
Archive archive = index.getArchive(0);
System.out.println(archive.getInfo());
CacheLibrary lib = new CacheLibrary("C:\\Users\\Maffia\\Documents\\RSPS\\RS3\\861\\861 Cache editing", CacheLibraryMode.UN_CACHED);
System.out.println(lib.getLastIndex());
}

}

0 comments on commit fde8e1e

Please sign in to comment.