Skip to content

Commit

Permalink
Merge pull request #10 from Displee/dev
Browse files Browse the repository at this point in the history
Updated writing for RS3
  • Loading branch information
Displee authored Dec 28, 2018
2 parents 8ec48e0 + f25e2d4 commit bd26659
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
Binary file modified RS2-Cache-Library.jar
Binary file not shown.
57 changes: 49 additions & 8 deletions src/org/displee/cache/index/IndexInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public class IndexInformation implements Container {
*/
protected boolean whirlpool;

/**
* An unknown flag.
*/
protected boolean flag4;

/**
* An unknown flag.
*/
protected boolean flag8;

/**
* An array of archive ids.
*/
Expand Down Expand Up @@ -92,8 +102,8 @@ public boolean read(InputStream inputStream) {
final int flag = inputStream.readByte();
named = (flag & 0x1) != 0;
whirlpool = (flag & 0x2) != 0;
boolean flag4 = (flag & 0x4) != 0;
boolean flag8 = (flag & 0x8) != 0;
flag4 = (flag & 0x4) != 0;
flag8 = (flag & 0x8) != 0;
archiveIds = new int[version >= 7 ? inputStream.readBigSmart() : inputStream.readUnsignedShort()];
int lastArchiveId = 0;
for (int i = 0; i < archiveIds.length; i++) {
Expand Down Expand Up @@ -179,7 +189,20 @@ public byte[] write(OutputStream outputStream) {
if (version >= 6) {
outputStream.writeInt(revision);
}
outputStream.writeByte((named ? 0x1 : 0x0) | (whirlpool ? 0x2 : 0x0));
int flag = 0x0;
if (named) {
flag |= 0x1;
}
if (whirlpool) {
flag |= 0x2;
}
if (flag4) {
flag |= 0x4;
}
if (flag8) {
flag |= 0x8;
}
outputStream.writeByte(flag);
if (version >= 7) {
outputStream.writeBigSmart(archives.length);
} else {
Expand All @@ -197,13 +220,31 @@ public byte[] write(OutputStream outputStream) {
outputStream.writeInt(archives[i].getName());
}
}
if (whirlpool) {
if (origin.isRS3()) {
for (int i = 0; i < archives.length; i++) {
outputStream.writeBytes(archives[i].getWhirlpool());
outputStream.writeInt(archives[i].getCRC());
}
for (int i = 0; i < archives.length; i++) {
outputStream.writeInt(archives[i].getFlag8Value());
}
if (whirlpool) {
for (int i = 0; i < archives.length; i++) {
outputStream.writeBytes(archives[i].getWhirlpool());
}
}
for (int i = 0; i < archives.length; i++) {
outputStream.writeInt(archives[i].getFlag4Value1());
outputStream.writeInt(archives[i].getFlag4Value2());
}
} else {
if (whirlpool) {
for (int i = 0; i < archives.length; i++) {
outputStream.writeBytes(archives[i].getWhirlpool());
}
}
for (int i = 0; i < archives.length; i++) {
outputStream.writeInt(archives[i].getCRC());
}
}
for (int i = 0; i < archives.length; i++) {
outputStream.writeInt(archives[i].getCRC());
}
for (int i = 0; i < archives.length; i++) {
outputStream.writeInt(archives[i].getRevision());
Expand Down

0 comments on commit bd26659

Please sign in to comment.