[jetrix-cvs] SF.net SVN: jetrix:[834] jetrix/trunk/src
Brought to you by:
smanux
From: <sm...@us...> - 2010-04-11 20:45:56
|
Revision: 834 http://jetrix.svn.sourceforge.net/jetrix/?rev=834&view=rev Author: smanux Date: 2010-04-11 20:45:49 +0000 (Sun, 11 Apr 2010) Log Message: ----------- Encode the strings in Cp1252 for the tetrinetx winlists to improve the compatibility Modified Paths: -------------- jetrix/trunk/src/java/net/jetrix/winlist/TetrixWinlist.java jetrix/trunk/src/test/net/jetrix/winlist/TetrixWinlistTest.java Modified: jetrix/trunk/src/java/net/jetrix/winlist/TetrixWinlist.java =================================================================== --- jetrix/trunk/src/java/net/jetrix/winlist/TetrixWinlist.java 2010-03-08 09:04:45 UTC (rev 833) +++ jetrix/trunk/src/java/net/jetrix/winlist/TetrixWinlist.java 2010-04-11 20:45:49 UTC (rev 834) @@ -25,7 +25,7 @@ import net.jetrix.config.*; /** - * A winlist caompatible with the tetrinetx winlist format. + * A winlist compatible with the tetrinetx winlist format. * * @author Emmanuel Bourg * @version $Revision$, $Date$ @@ -37,6 +37,7 @@ private long scoreCount = DEFAULT_WINLIST_SIZE; private String filename; + private String encoding = "Cp1252"; public void init(WinlistConfig config) { @@ -120,14 +121,14 @@ /** * Build a score from a tetrix winlist structure. */ - protected Score buildScore(byte[] struct) + protected Score buildScore(byte[] struct) throws IOException { Score score = null; if (struct[0] != 0) { score = new Score(); - score.setName(new String(struct, 1, 31).trim()); + score.setName(new String(struct, 1, 31, encoding).trim()); score.setType(struct[0] == 0x70 ? Score.TYPE_PLAYER : Score.TYPE_TEAM); long scoreValue = getUnsignedByte(struct, 32) + (getUnsignedByte(struct, 33) << 8) @@ -152,7 +153,7 @@ struct[0] = score.getType() == Score.TYPE_PLAYER ? (byte) 'p' : (byte) 't'; // name - byte[] name = score.getName().getBytes(ServerConfig.ENCODING); + byte[] name = score.getName().getBytes(encoding); System.arraycopy(name, 0, struct, 1, name.length); // score Modified: jetrix/trunk/src/test/net/jetrix/winlist/TetrixWinlistTest.java =================================================================== --- jetrix/trunk/src/test/net/jetrix/winlist/TetrixWinlistTest.java 2010-03-08 09:04:45 UTC (rev 833) +++ jetrix/trunk/src/test/net/jetrix/winlist/TetrixWinlistTest.java 2010-04-11 20:45:49 UTC (rev 834) @@ -37,7 +37,7 @@ public void setUp() { super.setUp(); - score = new Score("hell's_players\x86", Score.TYPE_TEAM, 1418); + score = new Score("hell's_players\u2020", Score.TYPE_TEAM, 1418); } public void testBuildScore() throws Exception @@ -51,7 +51,7 @@ assertEquals("type", score.getType(), score2.getType()); } - public void testBuildStruct() + public void testBuildStruct() throws Exception { TetrixWinlist winlist = new TetrixWinlist(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |