Rest of index loading? untested
This commit is contained in:
44
src/main/java/net/runelite/cache/fs/Archive.java
vendored
44
src/main/java/net/runelite/cache/fs/Archive.java
vendored
@@ -2,6 +2,7 @@ package net.runelite.cache.fs;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.runelite.cache.fs.io.InputStream;
|
||||||
|
|
||||||
public class Archive
|
public class Archive
|
||||||
{
|
{
|
||||||
@@ -18,6 +19,49 @@ public class Archive
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
this.archiveId = id;
|
this.archiveId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void load(InputStream stream, int numberOfFiles, int protocol)
|
||||||
|
{
|
||||||
|
int archive = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < numberOfFiles; ++i)
|
||||||
|
{
|
||||||
|
int fileId = archive += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
||||||
|
|
||||||
|
File file = new File(this, fileId);
|
||||||
|
this.files.add(file);
|
||||||
|
//archive1.getValidFileIds()[index21] = fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//archive1.setFiles(new FileReference[index2 + 1]);
|
||||||
|
|
||||||
|
// for (int i = 0; i < archive1.getValidFileIds().length; ++i) {
|
||||||
|
// archive1.getFiles()[archive1.getValidFileIds()[ki]] = new FileReference();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (this.named)
|
||||||
|
// {
|
||||||
|
// for (index = 0; index < validArchivesCount; ++index)
|
||||||
|
// {
|
||||||
|
// ArchiveReference var14 = this.archives[this.validArchiveIds[index]];
|
||||||
|
//
|
||||||
|
// for (index2 = 0; index2 < var14.getValidFileIds().length; ++index2)
|
||||||
|
// {
|
||||||
|
// var14.getFiles()[var14.getValidFileIds()[index2]].setNameHash(stream.readInt());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadNames(InputStream stream, int numberOfFiles)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numberOfFiles; ++i)
|
||||||
|
{
|
||||||
|
File file = this.files.get(i);
|
||||||
|
int name = stream.readInt();
|
||||||
|
file.setNameHash(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getNameHash()
|
public int getNameHash()
|
||||||
{
|
{
|
||||||
|
|||||||
26
src/main/java/net/runelite/cache/fs/File.java
vendored
26
src/main/java/net/runelite/cache/fs/File.java
vendored
@@ -5,4 +5,30 @@ public class File
|
|||||||
private Archive archive;
|
private Archive archive;
|
||||||
private int fileId;
|
private int fileId;
|
||||||
private int nameHash;
|
private int nameHash;
|
||||||
|
|
||||||
|
public File(Archive archive, int fileId)
|
||||||
|
{
|
||||||
|
this.archive = archive;
|
||||||
|
this.fileId = fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Archive getArchive()
|
||||||
|
{
|
||||||
|
return archive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFileId()
|
||||||
|
{
|
||||||
|
return fileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNameHash()
|
||||||
|
{
|
||||||
|
return nameHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameHash(int nameHash)
|
||||||
|
{
|
||||||
|
this.nameHash = nameHash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
64
src/main/java/net/runelite/cache/fs/Index.java
vendored
64
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -19,11 +19,14 @@ public class Index
|
|||||||
private byte[] whirlpool;
|
private byte[] whirlpool;
|
||||||
private List<Archive> archives = new ArrayList<>();
|
private List<Archive> archives = new ArrayList<>();
|
||||||
|
|
||||||
public Index(IndexFile index, int id) throws IOException
|
public Index(IndexFile index, int id)
|
||||||
{
|
{
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() throws IOException
|
||||||
|
{
|
||||||
// read data from index255
|
// read data from index255
|
||||||
Store store = index.getStore();
|
Store store = index.getStore();
|
||||||
DataFile dataFile = store.getData();
|
DataFile dataFile = store.getData();
|
||||||
@@ -89,8 +92,7 @@ public class Index
|
|||||||
int protocol = stream.readUnsignedByte();
|
int protocol = stream.readUnsignedByte();
|
||||||
if (protocol >= 5 && protocol <= 7) {
|
if (protocol >= 5 && protocol <= 7) {
|
||||||
if (protocol >= 6) {
|
if (protocol >= 6) {
|
||||||
not the right rev
|
int revision = stream.readInt(); // what is this and why is it different from checkRevision?
|
||||||
this.revision = stream.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hash = stream.readUnsignedByte();
|
int hash = stream.readUnsignedByte();
|
||||||
@@ -98,7 +100,7 @@ public class Index
|
|||||||
this.usesWhirpool = (2 & hash) != 0;
|
this.usesWhirpool = (2 & hash) != 0;
|
||||||
int validArchivesCount = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
int validArchivesCount = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
||||||
// this.validArchiveIds = new int[validArchivesCount];
|
// this.validArchiveIds = new int[validArchivesCount];
|
||||||
// int lastArchiveId = 0;
|
int lastArchiveId = 0;
|
||||||
// int biggestArchiveId = 0;
|
// int biggestArchiveId = 0;
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
@@ -168,32 +170,40 @@ public class Index
|
|||||||
for (index = 0; index < validArchivesCount; ++index) {
|
for (index = 0; index < validArchivesCount; ++index) {
|
||||||
archive = 0;
|
archive = 0;
|
||||||
index2 = 0;
|
index2 = 0;
|
||||||
ArchiveReference archive1 = this.archives[this.validArchiveIds[index]];
|
|
||||||
|
Archive a = this.archives.get(index);
|
||||||
|
a.load(stream, numberOfFiles[index], protocol);
|
||||||
|
//ArchiveReference archive1 = this.archives[this.validArchiveIds[index]];
|
||||||
|
|
||||||
int index21;
|
// int index21;
|
||||||
for (index21 = 0; index21 < archive1.getValidFileIds().length; ++index21) {
|
// for (index21 = 0; index21 < archive1.getValidFileIds().length; ++index21) {
|
||||||
int fileId = archive += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
// int fileId = archive += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
|
||||||
if (fileId > index2) {
|
// if (fileId > index2) {
|
||||||
index2 = fileId;
|
// index2 = fileId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
archive1.getValidFileIds()[index21] = fileId;
|
// archive1.getValidFileIds()[index21] = fileId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
archive1.setFiles(new FileReference[index2 + 1]);
|
// archive1.setFiles(new FileReference[index2 + 1]);
|
||||||
|
//
|
||||||
for (index21 = 0; index21 < archive1.getValidFileIds().length; ++index21) {
|
// for (index21 = 0; index21 < archive1.getValidFileIds().length; ++index21) {
|
||||||
archive1.getFiles()[archive1.getValidFileIds()[index21]] = new FileReference();
|
// archive1.getFiles()[archive1.getValidFileIds()[index21]] = new FileReference();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.named) {
|
if (this.named)
|
||||||
for (index = 0; index < validArchivesCount; ++index) {
|
{
|
||||||
ArchiveReference var14 = this.archives[this.validArchiveIds[index]];
|
for (index = 0; index < validArchivesCount; ++index)
|
||||||
|
{
|
||||||
|
Archive a = this.archives.get(index);
|
||||||
|
a.loadNames(stream, numberOfFiles[index]);
|
||||||
|
//ArchiveReference var14 = this.archives[this.validArchiveIds[index]];
|
||||||
|
|
||||||
for (index2 = 0; index2 < var14.getValidFileIds().length; ++index2) {
|
// for (index2 = 0; index2 < var14.getValidFileIds().length; ++index2)
|
||||||
var14.getFiles()[var14.getValidFileIds()[index2]].setNameHash(stream.readInt());
|
// {
|
||||||
}
|
// var14.getFiles()[var14.getValidFileIds()[index2]].setNameHash(stream.readInt());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user