Merge remote-tracking branch 'runelite/master'

This commit is contained in:
ThatGamerBlue
2020-09-08 18:36:30 +01:00
38 changed files with 525 additions and 930 deletions

View File

@@ -33,6 +33,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Comparator;
@@ -103,7 +104,7 @@ public class FlatStorage implements Storage
for (Index idx : store.getIndexes())
{
String file = idx.getId() + EXTENSION;
try (BufferedReader br = new BufferedReader(new InputStreamReader(openReader(file))))
try (BufferedReader br = new BufferedReader(new InputStreamReader(openReader(file), StandardCharsets.UTF_8)))
{
int lineNo = 0;
Archive archive = null;
@@ -213,7 +214,7 @@ public class FlatStorage implements Storage
for (Index idx : store.getIndexes())
{
String file = idx.getId() + EXTENSION;
try (PrintStream br = new PrintStream(openWriter(file)))
try (PrintStream br = new PrintStream(openWriter(file), false, StandardCharsets.UTF_8.name()))
{
br.printf("protocol=%d\n", idx.getProtocol());
br.printf("revision=%d\n", idx.getRevision());

View File

@@ -26,10 +26,8 @@ package net.runelite.cache.io;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
public final class OutputStream extends java.io.OutputStream
{
@@ -183,23 +181,13 @@ public final class OutputStream extends java.io.OutputStream
public void writeString(String str)
{
Charset utf8charset = Charset.forName("UTF-8");
Charset cp1252charset = Charset.forName("Cp1252");
ByteBuffer inputBuffer = ByteBuffer.wrap(str.getBytes());
CharBuffer data = utf8charset.decode(inputBuffer);
ByteBuffer outputBuffer = cp1252charset.encode(data);
byte[] outputData = outputBuffer.array();
writeBytes(outputData);
writeBytes(str.getBytes(StandardCharsets.ISO_8859_1));
writeByte(0);
}
public byte[] flip()
{
((Buffer) buffer).flip();
buffer.flip();
byte[] b = new byte[buffer.limit()];
buffer.get(b);
return b;

View File

@@ -26,10 +26,12 @@ package net.runelite.cache.script.assembler;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import net.runelite.cache.definitions.ScriptDefinition;
import net.runelite.cache.script.Instructions;
import net.runelite.cache.script.assembler.rs2asmParser.ProgContext;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
@@ -45,7 +47,7 @@ public class Assembler
public ScriptDefinition assemble(InputStream in) throws IOException
{
// Get our lexer
rs2asmLexer lexer = new rs2asmLexer(CharStreams.fromStream(in));
rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(new InputStreamReader(in, StandardCharsets.UTF_8)));
LexerErrorListener errorListener = new LexerErrorListener();
lexer.addErrorListener(errorListener);