# HG changeset patch
# User unc0rr
# Date 1209586710 0
# Node ID dfe97199f17e7e8fffea05ee8e9edfc1c5c578bb
# Parent  701f86df9b4cb12325bd610ca0e702005ccab8eb
Better QUIT handling imlementation - reduces function return values count

diff -r 701f86df9b4c -r dfe97199f17e netserver/HWProto.hs
--- a/netserver/HWProto.hs	Wed Apr 30 20:14:09 2008 +0000
+++ b/netserver/HWProto.hs	Wed Apr 30 20:18:30 2008 +0000
@@ -3,12 +3,12 @@
 import IO
 import Miscutils
 
-handleCmd :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (Bool, [ClientInfo], [String])
+handleCmd :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> ([ClientInfo], [String])
 
 handleCmd client clients _ ("QUIT":xs) =
 	if null (room client) then
-		(True, [client], ["QUIT"])
+		([client], ["QUIT"])
 	else
-		(True, clients, ["QUIT " ++ nick client])
+		(clients, ["QUIT", nick client])
 
-handleCmd client _ _ _ = (False, [client], ["Bad command"])
+handleCmd client _ _ _ = ([client], ["Bad command"])
diff -r 701f86df9b4c -r dfe97199f17e netserver/newhwserv.hs
--- a/netserver/newhwserv.hs	Wed Apr 30 20:14:09 2008 +0000
+++ b/netserver/newhwserv.hs	Wed Apr 30 20:18:30 2008 +0000
@@ -39,7 +39,7 @@
 		Left ci -> do
 			mainLoop servSock acceptChan (ci:clients) rooms
 		Right (line, client) -> do
-			let (doQuit, recipients, strs) = handleCmd client sameRoom rooms $ words line
+			let (recipients, strs) = handleCmd client sameRoom rooms $ words line
 
 			clients' <- forM recipients $
 					\ci -> do
@@ -48,7 +48,7 @@
 							return []
 					`catch` const (hClose (handle ci) >> return [ci])
 
-			client' <- if doQuit then hClose (handle client) >> return [client] else return []
+			client' <- if head strs == "QUIT" then hClose (handle client) >> return [client] else return []
 
 			mainLoop servSock acceptChan (remove (remove clients (concat clients')) client') rooms
 			where