mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-09 23:38:15 +07:00
Workaround for issue #9
This commit is contained in:
@ -237,6 +237,7 @@ public class Client extends Game {
|
|||||||
Riiablo.mpqs = mpqs = new MPQFileHandleResolver();
|
Riiablo.mpqs = mpqs = new MPQFileHandleResolver();
|
||||||
mpqs.add(home.child("patch_d2.mpq"));
|
mpqs.add(home.child("patch_d2.mpq"));
|
||||||
mpqs.add(home.child("d2exp.mpq"));
|
mpqs.add(home.child("d2exp.mpq"));
|
||||||
|
mpqs.delete("data\\global\\sfx\\Item\\gem.wav"); // workaround for issue #9
|
||||||
mpqs.add(home.child("d2xmusic.mpq"));
|
mpqs.add(home.child("d2xmusic.mpq"));
|
||||||
mpqs.add(home.child("d2xtalk.mpq"));
|
mpqs.add(home.child("d2xtalk.mpq"));
|
||||||
mpqs.add(home.child("d2xvideo.mpq"));
|
mpqs.add(home.child("d2xvideo.mpq"));
|
||||||
|
@ -49,6 +49,11 @@ public class MPQ {
|
|||||||
return hashTable.contains(fileName);
|
return hashTable.contains(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean delete(String fileName) {
|
||||||
|
fileName = fileName.replaceAll("/", "\\\\");
|
||||||
|
return hashTable.deleteEntry(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public long length(String fileName) {
|
public long length(String fileName) {
|
||||||
fileName = fileName.replaceAll("/", "\\\\");
|
fileName = fileName.replaceAll("/", "\\\\");
|
||||||
HashTable.Entry entry = hashTable.getEntry(fileName);
|
HashTable.Entry entry = hashTable.getEntry(fileName);
|
||||||
@ -238,6 +243,15 @@ public class MPQ {
|
|||||||
return index != -1 ? entries[index] : null;
|
return index != -1 ? entries[index] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean deleteEntry(String file) {
|
||||||
|
Entry entry = getEntry(file);
|
||||||
|
System.out.println("deleting entry " + entry);
|
||||||
|
if (entry == null || entry.blockIndex == Entry.DELETED) return false;
|
||||||
|
entry.blockIndex = Entry.DELETED;
|
||||||
|
System.out.println("-> " + entry);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(String file) {
|
public boolean contains(String file) {
|
||||||
return getIndex(File.key(file), File.offset(file), Entry.DEFAULT_LOCALE) != -1;
|
return getIndex(File.key(file), File.offset(file), Entry.DEFAULT_LOCALE) != -1;
|
||||||
}
|
}
|
||||||
@ -276,7 +290,7 @@ public class MPQ {
|
|||||||
final long key; // QWORD
|
final long key; // QWORD
|
||||||
final short locale; // WORD
|
final short locale; // WORD
|
||||||
final short platform; // WORD
|
final short platform; // WORD
|
||||||
final int blockIndex; // DWORD
|
int blockIndex; // DWORD
|
||||||
|
|
||||||
Entry(ByteBuffer in) {
|
Entry(ByteBuffer in) {
|
||||||
key = in.getLong();
|
key = in.getLong();
|
||||||
|
@ -20,6 +20,12 @@ public class MPQFileHandleResolver implements FileHandleResolver {
|
|||||||
add(MPQ.loadFromFile(file));
|
add(MPQ.loadFromFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean delete(String fileName) {
|
||||||
|
boolean deleted = false;
|
||||||
|
for (MPQ mpq : mpqs) deleted = mpq.delete(fileName);
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(String fileName) {
|
public boolean contains(String fileName) {
|
||||||
for (MPQ mpq : mpqs) {
|
for (MPQ mpq : mpqs) {
|
||||||
if (mpq.contains(fileName)) {
|
if (mpq.contains(fileName)) {
|
||||||
|
Reference in New Issue
Block a user