# HG changeset patch
# User unc0rr
# Date 1296297787 -10800
# Node ID 9541b2a7606752b0309b8f15d51a6e275aceb5ad
# Parent  d0f758d0ff91221f7c36d62b9b6fcaa5cbc06f43
Introduce numbered server notice messages

diff -r d0f758d0ff91 -r 9541b2a76067 gameServer/Actions.hs
--- a/gameServer/Actions.hs	Fri Jan 28 22:34:07 2011 +0300
+++ b/gameServer/Actions.hs	Sat Jan 29 13:43:07 2011 +0300
@@ -32,6 +32,7 @@
     | JoinLobby
     | ProtocolError B.ByteString
     | Warning B.ByteString
+    | NoticeMessage Notice
     | ByeClient B.ByteString
     | KickClient ClientIndex
     | KickRoomClient ClientIndex
@@ -103,6 +104,10 @@
     chan <- client's sendChan
     processAction $ AnswerClients [chan] ["WARNING", msg]
 
+processAction (NoticeMessage n) = do
+    chan <- client's sendChan
+    processAction $ AnswerClients [chan] ["NOTICE", B.pack . show . fromEnum $ n]
+
 processAction (ByeClient msg) = do
     (Just ci) <- gets clientIndex
     rnc <- gets roomsClients
diff -r d0f758d0ff91 -r 9541b2a76067 gameServer/CoreTypes.hs
--- a/gameServer/CoreTypes.hs	Fri Jan 28 22:34:07 2011 +0300
+++ b/gameServer/CoreTypes.hs	Sat Jan 29 13:43:07 2011 +0300
@@ -179,7 +179,9 @@
     show (ClientAccountInfo _) = "ClientAccountInfo"
     show (TimerAction _) = "TimerAction"
     show (Remove _) = "Remove"
-    
+
 type MRnC = MRoomsAndClients RoomInfo ClientInfo
 type IRnC = IRoomsAndClients RoomInfo ClientInfo
 
+data Notice = NickAlreadyInUse
+    deriving Enum
\ No newline at end of file
diff -r d0f758d0ff91 -r 9541b2a76067 gameServer/HWProtoNEState.hs
--- a/gameServer/HWProtoNEState.hs	Fri Jan 28 22:34:07 2011 +0300
+++ b/gameServer/HWProtoNEState.hs	Sat Jan 29 13:43:07 2011 +0300
@@ -20,7 +20,7 @@
     let cl = irnc `client` ci
     if not . B.null $ nick cl then return [ProtocolError "Nickname already chosen"]
         else
-        if haveSameNick irnc then return [{-AnswerClients [sendChan cl] ["WARNING", "Nickname already in use"], -}ByeClient "Nickname already in use"]
+        if haveSameNick irnc then return [NoticeMessage NickAlreadyInUse]
             else
             if illegalName newNick then return [ByeClient "Illegal nickname"]
                 else
@@ -57,10 +57,5 @@
         else
         return [ByeClient "Authentication failed"]
 
-{-
-
-handleCmd_NotEntered clID clients _ ["DUMP"] =
-    if isAdministrator (clients IntMap.! clID) then [Dump] else []
--}
 
 handleCmd_NotEntered _ = return [ProtocolError "Incorrect command (state: not entered)"]