mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-24 21:48:46 +07:00
Created Decryptor.LookupTable#fix(String) to return a valid translated path string
This commit is contained in:
parent
e2c00d7336
commit
f2ec4c9c2e
@ -7,10 +7,11 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import com.riiablo.mpq_bytebuf.util.Decryptor;
|
||||
|
||||
public final class MPQFileHandle extends FileHandle {
|
||||
public final MPQ mpq;
|
||||
public final String filename;
|
||||
@ -34,9 +35,8 @@ public final class MPQFileHandle extends FileHandle {
|
||||
}
|
||||
|
||||
MPQFileHandle(MPQ mpq, String filename, long key, int offset, short locale, MPQ.Entry entry) {
|
||||
assert !StringUtils.contains(filename, '/');
|
||||
this.mpq = mpq;
|
||||
this.filename = filename;
|
||||
this.filename = Decryptor.LookupTable.fix(filename);
|
||||
this.key = key;
|
||||
this.offset = offset;
|
||||
this.locale = locale;
|
||||
|
@ -310,5 +310,12 @@ public final class Decryptor {
|
||||
|
||||
return seed1;
|
||||
}
|
||||
|
||||
public static String fix(String str) {
|
||||
final byte[] byteMap = LookupTable.byteMap;
|
||||
final byte[] bytes = str.getBytes(StandardCharsets.US_ASCII);
|
||||
for (int i = 0, s = bytes.length; i < s; i++) bytes[i] = byteMap[bytes[i]];
|
||||
return new String(bytes, StandardCharsets.US_ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user