# HG changeset patch # User unc0rr # Date 1244360560 0 # Node ID 45b695f3a7b9cd1be63fe615e57241c536b5407d # Parent 2eda77999bec4ab19c9a021d2428552047f73fe8 Forbid room names and nicknames consisting only of space characters diff -r 2eda77999bec -r 45b695f3a7b9 gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Sat Jun 06 12:42:35 2009 +0000 +++ b/gameServer/HWProtoLobbyState.hs Sun Jun 07 07:42:40 2009 +0000 @@ -44,6 +44,8 @@ handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, roomPassword] = if haveSameRoom then [Warning "Room exists"] + else if illegalName newRoom then + [Warning "Illegal room name"] else [RoomRemoveThisClient "", -- leave lobby AddRoom newRoom roomPassword, diff -r 2eda77999bec -r 45b695f3a7b9 gameServer/HWProtoNEState.hs --- a/gameServer/HWProtoNEState.hs Sat Jun 06 12:42:35 2009 +0000 +++ b/gameServer/HWProtoNEState.hs Sun Jun 07 07:42:40 2009 +0000 @@ -13,10 +13,12 @@ handleCmd_NotEntered clID clients _ ["NICK", newNick] = if not . null $ nick client then - [ProtocolError "Nick already chosen"] + [ProtocolError "Nickname already chosen"] else if haveSameNick then - [AnswerThisClient ["WARNING", "Nick collision"]] + [AnswerThisClient ["WARNING", "Nickname collision"]] ++ [ByeClient ""] + else if illegalName newNick then + [ByeClient "Illegal nickname"] else [ModifyClient (\c -> c{nick = newNick}), AnswerThisClient ["NICK", newNick]] diff -r 2eda77999bec -r 45b695f3a7b9 gameServer/Utils.hs --- a/gameServer/Utils.hs Sat Jun 06 12:42:35 2009 +0000 +++ b/gameServer/Utils.hs Sun Jun 07 07:42:40 2009 +0000 @@ -57,6 +57,9 @@ else t : replaceTeam team teams +illegalName :: String -> Bool +illegalName str = all isSpace str + protoNumber2ver :: Word16 -> String protoNumber2ver 17 = "0.9.7-dev" protoNumber2ver 19 = "0.9.7"