【相關網址】
 AICL楓之谷私服論壇技術討論區:點此

首先至GenericLittleEndianWriter.java
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
02
03
04
05
06
07
08
09
10
11
12
13
public int getlength(String str) {
    int i, t = 0;
    byte[] bt = str.getBytes();
    for (i = 1; i <= bt.length; i++) {
        if (bt[i - 1] < 0) {
            t = t + 2;
            i++;
        } else {
            t = t + 1;
        }
    }
    return t;
}

取代為
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
02
03
04
public static final int getlength(final String str) {
    byte[] bt = str.getBytes(ASCII);
    return bt.length;
}


接著在適當位置加入
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
02
03
04
05
06
07
08
09
10
@Override
public void writeAsciiString(String s, int length) {
    if (getlength(s) > length) {
        s = s.substring(0, length);
    }
    write(s.getBytes(ASCII));
    for (int i = getlength(s); i < length; i++) {
        write(0);
    }
}


LittleEndianWriter.java
在適當位置加入
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
public void writeAsciiString(String s, int length);


MaplePacketCreator.java 找到 (有2段要改)
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
02
03
04
05
06
07
if (petname.length() > 13) {
               petname = petname.substring(0, 13);
           }
           mplew.writeAsciiString(petname);
           for (int i = petname.length(); i < 13; i++) {
               mplew.write(0);
           }

改為
[Java] syntaxhighlighter_viewsource syntaxhighlighter_copycode
?
01
mplew.writeAsciiString(petname, 13);



最後則是到 db.properties
將 url=jdbc:mysql://localhost:3306/pony
改為 url=jdbc:mysql://localhost:3306/pony?characterEncoding=UTF8
來使資料庫使用中文編碼



作者:宗達
原文:點此

發表評論

Subscribe to Posts | Subscribe to Comments

- Copyright © AICL社群娛樂集團 - 網站區 - Date A Live - Powered by Blogger - Designed by Johanes Djogan -