mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-22 02:07:26 +07:00
Effectively renamed #writeString methods to #writeChars (see #136)
This commit is contained in:
parent
7b8ea9511b
commit
eec17d0a01
@ -112,21 +112,36 @@ public class ByteOutput {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteOutput writeString(CharSequence chars) {
|
||||
// TODO: create readChars int com.riiablo.io.BitInput
|
||||
// Chars methods for explicit chars
|
||||
// String methods for implicit null-termination
|
||||
public ByteOutput writeChars(CharSequence chars) {
|
||||
assert aligned() : "not aligned";
|
||||
incrementBitsWritten((long) chars.length() * Byte.SIZE);
|
||||
buffer.writeCharSequence(chars, CharsetUtil.US_ASCII);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteOutput writeString(CharSequence chars, int len) {
|
||||
public ByteOutput writeChars(CharSequence chars, int len) {
|
||||
if (len < 0) throw new IllegalArgumentException("len(" + len + ") < " + 0);
|
||||
assert aligned() : "not aligned";
|
||||
final int charsLength = chars.length();
|
||||
if (len <= charsLength) {
|
||||
return writeString(chars.subSequence(0, len));
|
||||
return writeChars(chars.subSequence(0, len));
|
||||
} else {
|
||||
return writeString(chars).skipBytes(len - charsLength);
|
||||
return writeChars(chars).skipBytes(len - charsLength);
|
||||
}
|
||||
}
|
||||
|
||||
public ByteOutput writeString(CharSequence chars) {
|
||||
return writeChars(chars).skipBytes(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated until fixed and null termination
|
||||
*/
|
||||
// @Deprecated
|
||||
// public ByteOutput writeString(CharSequence chars, int len) {
|
||||
// throw new UnsupportedOperationException("Not supported yet!");
|
||||
// }
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class D2SWriter96 {
|
||||
out.write32(d2s.size);
|
||||
out.write32(d2s.checksum);
|
||||
out.write32(d2s.alternate);
|
||||
out.writeString(d2s.name, Riiablo.MAX_NAME_LENGTH + 1);
|
||||
out.writeChars(d2s.name, Riiablo.MAX_NAME_LENGTH + 1);
|
||||
out.write32(d2s.flags);
|
||||
out.write8(d2s.charClass);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user