Forbid room names and nicknames consisting only of space characters
authorunc0rr
Sun, 07 Jun 2009 07:42:40 +0000
changeset 2150 45b695f3a7b9
parent 2149 2eda77999bec
child 2151 541d3a475442
Forbid room names and nicknames consisting only of space characters
gameServer/HWProtoLobbyState.hs
gameServer/HWProtoNEState.hs
gameServer/Utils.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,
--- 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]]
--- 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"