gameServer/Actions.hs
changeset 5030 42746c5d4a80
parent 5008 af9e4a66111b
child 5059 68a5415ca8ea
equal deleted inserted replaced
5028:3c43f00b0743 5030:42746c5d4a80
   101     io $ writeChan chan ("SERVER_VARS" : vars si)
   101     io $ writeChan chan ("SERVER_VARS" : vars si)
   102     where
   102     where
   103         vars si = [
   103         vars si = [
   104             "MOTD_NEW", serverMessage si,
   104             "MOTD_NEW", serverMessage si,
   105             "MOTD_OLD", serverMessageForOldVersions si,
   105             "MOTD_OLD", serverMessageForOldVersions si,
   106             "LATEST_PROTO", B.pack . show $ latestReleaseVersion si
   106             "LATEST_PROTO", showB $ latestReleaseVersion si
   107             ]
   107             ]
   108 
   108 
   109 
   109 
   110 processAction (ProtocolError msg) = do
   110 processAction (ProtocolError msg) = do
   111     chan <- client's sendChan
   111     chan <- client's sendChan
   116     chan <- client's sendChan
   116     chan <- client's sendChan
   117     processAction $ AnswerClients [chan] ["WARNING", msg]
   117     processAction $ AnswerClients [chan] ["WARNING", msg]
   118 
   118 
   119 processAction (NoticeMessage n) = do
   119 processAction (NoticeMessage n) = do
   120     chan <- client's sendChan
   120     chan <- client's sendChan
   121     processAction $ AnswerClients [chan] ["NOTICE", B.pack . show . fromEnum $ n]
   121     processAction $ AnswerClients [chan] ["NOTICE", showB . fromEnum $ n]
   122 
   122 
   123 processAction (ByeClient msg) = do
   123 processAction (ByeClient msg) = do
   124     (Just ci) <- gets clientIndex
   124     (Just ci) <- gets clientIndex
   125     ri <- clientRoomA
   125     ri <- clientRoomA
   126 
   126 
   299                     leftTeams = teamName : leftTeams r,
   299                     leftTeams = teamName : leftTeams r,
   300                     roundMsgs = roundMsgs r Seq.|> rmTeamMsg
   300                     roundMsgs = roundMsgs r Seq.|> rmTeamMsg
   301                     })
   301                     })
   302                 ]
   302                 ]
   303     where
   303     where
   304         rmTeamMsg = toEngineMsg $ B.singleton 'F' `B.append` teamName
   304         rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName
   305 
   305 
   306 
   306 
   307 processAction (RemoveClientTeams clId) = do
   307 processAction (RemoveClientTeams clId) = do
   308     rnc <- gets roomsClients
   308     rnc <- gets roomsClients
   309 
   309 
   374 
   374 
   375 processAction (BanClient seconds reason banId) = do
   375 processAction (BanClient seconds reason banId) = do
   376     modify (\s -> s{clientIndex = Just banId})
   376     modify (\s -> s{clientIndex = Just banId})
   377     clHost <- client's host
   377     clHost <- client's host
   378     currentTime <- io getCurrentTime
   378     currentTime <- io getCurrentTime
   379     let msg = "Ban for " `B.append` (B.pack . show $ seconds) `B.append` "seconds (" `B.append` reason ` B.append` ")"
   379     let msg = B.concat ["Ban for ", B.pack . show $ seconds, "seconds (", reason, ")"]
   380     mapM_ processAction [
   380     mapM_ processAction [
   381         AddIP2Bans clHost msg (addUTCTime seconds currentTime)
   381         AddIP2Bans clHost msg (addUTCTime seconds currentTime)
   382         , KickClient banId
   382         , KickClient banId
   383         ]
   383         ]
   384 
   384