# HG changeset patch
# User unc0rr
# Date 1239998301 0
# Node ID d909152bdc21a382ab1b62979b4cbd9ba341db13
# Parent  f9f47e681aad94449062c33592262614b11be05d
 - More verbose output
 - Fix one way of crashing server

diff -r f9f47e681aad -r d909152bdc21 gameServer/Actions.hs
--- a/gameServer/Actions.hs	Fri Apr 17 17:02:24 2009 +0000
+++ b/gameServer/Actions.hs	Fri Apr 17 19:58:21 2009 +0000
@@ -117,6 +117,7 @@
 
 
 processAction (clID, serverInfo, clients, rooms) (ByeClient msg) = do
+	infoM "Clients" ((show $ clientUID client) ++ " quits: " ++ msg)
 	(_, _, newClients, newRooms) <-
 			if roomID client /= 0 then
 				processAction  (clID, serverInfo, clients, rooms)
diff -r f9f47e681aad -r d909152bdc21 gameServer/ClientIO.hs
--- a/gameServer/ClientIO.hs	Fri Apr 17 17:02:24 2009 +0000
+++ b/gameServer/ClientIO.hs	Fri Apr 17 19:58:21 2009 +0000
@@ -8,18 +8,21 @@
 ----------------
 import CoreTypes
 
-listenLoop :: Handle -> [String] -> Chan CoreMessage -> Int -> IO ()
-listenLoop handle buf chan clientID = do
+listenLoop :: Handle -> Int -> [String] -> Chan CoreMessage -> Int -> IO ()
+listenLoop handle linesNumber buf chan clientID = do
 	str <- hGetLine handle
-	if str == "" then do
-		writeChan chan $ ClientMessage (clientID, buf)
-		listenLoop handle [] chan clientID
+	if (linesNumber > 50) || (length str > 450) then
+		writeChan chan $ ClientMessage (clientID, ["QUIT", "Protocol violation"])
 		else
-		listenLoop handle (buf ++ [str]) chan clientID
+		if str == "" then do
+			writeChan chan $ ClientMessage (clientID, buf)
+			listenLoop handle 0 [] chan clientID
+			else
+			listenLoop handle (linesNumber + 1) (buf ++ [str]) chan clientID
 
 clientRecvLoop :: Handle -> Chan CoreMessage -> Int -> IO ()
 clientRecvLoop handle chan clientID =
-	listenLoop handle [] chan clientID
+	listenLoop handle 0 [] chan clientID
 		`catch` (\e -> (clientOff $ show e) >> return ())
 	where clientOff msg = writeChan chan $ ClientMessage (clientID, ["QUIT", msg]) -- if the client disconnects, we perform as if it sent QUIT message