Improve handling client's protocol number
authorunc0rr
Wed, 22 Oct 2008 21:34:03 +0000
changeset 1401 2087672a2114
parent 1400 8196ce1d9be1
child 1402 c164f215f7d2
Improve handling client's protocol number
netserver/HWProto.hs
--- a/netserver/HWProto.hs	Wed Oct 22 21:11:02 2008 +0000
+++ b/netserver/HWProto.hs	Wed Oct 22 21:34:03 2008 +0000
@@ -107,9 +107,10 @@
 -- 'noRoom' clients state command handlers
 handleCmd_noRoom :: CmdHandler
 handleCmd_noRoom client _ rooms ["LIST"] =
-		(noChangeClients, noChangeRooms, answerServerMessage ++ (answerRoomsList $ concat $ map roomInfo rooms))
+		(noChangeClients, noChangeRooms, answerServerMessage ++ (answerRoomsList $ concatMap roomInfo $ sameProtoRooms))
 		where
 			roomInfo room = [name room, show $ playersIn room, show $ gameinprogress room]
+			sameProtoRooms = filter (\r -> roomProto r == protocol client) rooms
 
 handleCmd_noRoom client _ rooms ["CREATE", newRoom, roomPassword] =
 	if (not $ isDedicated globalOptions) && (not $ null rooms) then
@@ -133,7 +134,7 @@
 	else
 		(modifyClient client{room = roomName}, modifyRoom clRoom{playersIn = 1 + playersIn clRoom}, answerNicks ++ (answerJoined $ nick client) ++ answerFullConfig clRoom ++ answerAllTeams clRoom)
 	where
-		noSuchRoom = isNothing $ find (\room -> roomName == name room) rooms
+		noSuchRoom = isNothing $ find (\room -> roomName == name room && roomProto room == protocol client) rooms
 		answerNicks = [(clientOnly, ["JOINED"] ++ (map nick $ filter (\ci -> room ci == roomName) clients))]
 		clRoom = roomByName roomName rooms