[jetrix-cvs] SF.net SVN: jetrix:[863] jetrix/trunk
Brought to you by:
smanux
From: <sm...@us...> - 2010-08-20 10:26:31
|
Revision: 863 http://jetrix.svn.sourceforge.net/jetrix/?rev=863&view=rev Author: smanux Date: 2010-08-20 10:26:25 +0000 (Fri, 20 Aug 2010) Log Message: ----------- Fixed the parsing of team messages when the name contains a space character Modified Paths: -------------- jetrix/trunk/doc/changelog.txt jetrix/trunk/src/java/net/jetrix/protocols/TetrinetProtocol.java jetrix/trunk/src/test/net/jetrix/protocols/TetrinetProtocolTest.java Modified: jetrix/trunk/doc/changelog.txt =================================================================== --- jetrix/trunk/doc/changelog.txt 2010-08-20 10:17:33 UTC (rev 862) +++ jetrix/trunk/doc/changelog.txt 2010-08-20 10:26:25 UTC (rev 863) @@ -11,7 +11,8 @@ - Added support for the client identification protocol (i.e lvl 0 0 request, clientinfo response) - The number of players and spectators currently online is now displayed on logging in - The 'TServ' mode of TSpec is now supported -- Channels can be dedicated to TetriFast or non TetriFast clients. +- Channels can be dedicated to TetriFast or non TetriFast clients. A warning is displayed when mixed clients play together. +- Spaces in team names are now properly handled Admin visible changes - Jetrix now requires Java 6 Modified: jetrix/trunk/src/java/net/jetrix/protocols/TetrinetProtocol.java =================================================================== --- jetrix/trunk/src/java/net/jetrix/protocols/TetrinetProtocol.java 2010-08-20 10:17:33 UTC (rev 862) +++ jetrix/trunk/src/java/net/jetrix/protocols/TetrinetProtocol.java 2010-08-20 10:26:25 UTC (rev 863) @@ -152,7 +152,10 @@ { TeamMessage team = new TeamMessage(); team.setSlot(Integer.parseInt(st.nextToken())); - team.setName(st.hasMoreTokens() ? st.nextToken() : null); + if (st.hasMoreTokens()) + { + team.setName(line.substring("team".length() + 3).trim()); + } m = team; m.setRawMessage(this, line); } Modified: jetrix/trunk/src/test/net/jetrix/protocols/TetrinetProtocolTest.java =================================================================== --- jetrix/trunk/src/test/net/jetrix/protocols/TetrinetProtocolTest.java 2010-08-20 10:17:33 UTC (rev 862) +++ jetrix/trunk/src/test/net/jetrix/protocols/TetrinetProtocolTest.java 2010-08-20 10:26:25 UTC (rev 863) @@ -186,6 +186,34 @@ assertEquals("name", null, team.getName()); } + public void testGetMessageTeam3() + { + // check the parsing of a team name containing a space character + String raw = "team 1 L F J R"; + Message message = protocol.getMessage(raw); + + assertNotNull("message not parsed", message); + assertEquals("message class", TeamMessage.class, message.getClass()); + + TeamMessage team = (TeamMessage) message; + assertEquals("slot", 1, team.getSlot()); + assertEquals("name", "L F J R", team.getName()); + } + + public void testGetMessageTeam4() + { + // check the parsing of a team name containing a leading and a trailing space character + String raw = "team 1 LFJR "; + Message message = protocol.getMessage(raw); + + assertNotNull("message not parsed", message); + assertEquals("message class", TeamMessage.class, message.getClass()); + + TeamMessage team = (TeamMessage) message; + assertEquals("slot", 1, team.getSlot()); + assertEquals("name", "LFJR", team.getName()); + } + public void testTranslatePlayerLeave() { LeaveMessage message = new LeaveMessage(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |