v117.2 日本語化
いろいろあった結果、バージョンはv117.2で落ち着きました。
MapleCrystalを使用しています。備忘録として日本語表示できるまでを残しておきます。
多分Lithiumベースのリパックならこれでできると思います。
tools.data.MaplePacketLittleEndianWriter.java
- 追加
private static final Charset MS932 = Charset.forName("MS932");
- 変更
変更前
public final void writeAsciiString(final String s) { write(s.getBytes(ASCII)); } public final void writeAsciiString(String s, final int max) { if (s.length() > max) { s = s.substring(0, max); } write(s.getBytes(ASCII)); for (int i = s.length(); i < max; i++) { write(0); } } public final void writeMapleAsciiString(final String s) { writeShort((short) s.length()); writeAsciiString(s); }
変更後
public final void writeAsciiString(final String s) { write(s.getBytes(MS932)); } public final void writeAsciiString(String s, final int max) { if (s.getBytes(MS932).length > max) { s = s.substring(0, max); } write(s.getBytes(MS932)); for (int i = s.getBytes(MS932).length; i < max; i++) { write(0); } } public final void writeMapleAsciiString(final String s) { writeShort((short) s.getBytes(MS932).length); writeAsciiString(s); }
tools.data.LittleEndianAccessor.java
- 変更
変更前
public final String readAsciiString(final int n) { final char ret[] = new char[n]; for (int x = 0; x < n; x++) { ret[x] = (char) readByte(); } return new String(ret); }
変更後
public final String readAsciiString(final int n) { //char ret[] = new char[n]; final byte ret[] = new byte[n]; for (int x = 0; x < n; x++) { ret[x] = (byte) readByte(); } try { String str = new String(ret, "MS932"); return str; } catch (Exception e) { System.err.println(e); } return null; }
tools.StringUtil.java
- 追加
import java.nio.charset.Charset; private static final Charset MS932 = Charset.forName("MS932");
- 変更(RightとLeftで二箇所)
変更前
for (int x = in.length(); x < length; x++) {
変更後
for (int x = in.getBytes(MS932).length; x < length; x++) {
Linux環境では内部の文字コードがutf8なのでgetBytes()としてしまうとMS932とバイト数に差が出るためエラーが起きる。
getBytes(MS932)とすることで解決。
キャラクター名なども問題なく日本語が使えます。
おわり