equal
deleted
inserted
replaced
54 | BanIP B.ByteString NominalDiffTime B.ByteString |
54 | BanIP B.ByteString NominalDiffTime B.ByteString |
55 | BanNick B.ByteString NominalDiffTime B.ByteString |
55 | BanNick B.ByteString NominalDiffTime B.ByteString |
56 | BanList |
56 | BanList |
57 | Unban B.ByteString |
57 | Unban B.ByteString |
58 | ChangeMaster (Maybe ClientIndex) |
58 | ChangeMaster (Maybe ClientIndex) |
59 | RemoveClientTeams ClientIndex |
59 | RemoveClientTeams |
60 | ModifyClient (ClientInfo -> ClientInfo) |
60 | ModifyClient (ClientInfo -> ClientInfo) |
61 | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo) |
61 | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo) |
62 | ModifyRoomClients (ClientInfo -> ClientInfo) |
62 | ModifyRoomClients (ClientInfo -> ClientInfo) |
63 | ModifyRoom (RoomInfo -> RoomInfo) |
63 | ModifyRoom (RoomInfo -> RoomInfo) |
64 | ModifyServerInfo (ServerInfo -> ServerInfo) |
64 | ModifyServerInfo (ServerInfo -> ServerInfo) |
234 clNick <- client's nick |
234 clNick <- client's nick |
235 chans <- othersChans |
235 chans <- othersChans |
236 |
236 |
237 if master then |
237 if master then |
238 if playersNum > 1 then |
238 if playersNum > 1 then |
239 mapM_ processAction [ChangeMaster Nothing, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] |
239 mapM_ processAction [ChangeMaster Nothing, NoticeMessage AdminLeft, RemoveClientTeams, AnswerClients chans ["LEFT", clNick, msg]] |
240 else |
240 else |
241 processAction RemoveRoom |
241 processAction RemoveRoom |
242 else |
242 else |
243 mapM_ processAction [RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] |
243 mapM_ processAction [RemoveClientTeams, AnswerClients chans ["LEFT", clNick, msg]] |
244 |
244 |
245 -- when not removing room |
245 -- when not removing room |
246 ready <- client's isReady |
246 ready <- client's isReady |
247 when (not master || playersNum > 1) . io $ do |
247 when (not master || playersNum > 1) . io $ do |
248 modifyRoom rnc (\r -> r{ |
248 modifyRoom rnc (\r -> r{ |
388 where |
388 where |
389 rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName |
389 rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName |
390 |
390 |
391 |
391 |
392 processAction (RemoveTeam teamName) = do |
392 processAction (RemoveTeam teamName) = do |
393 rnc <- gets roomsClients |
393 (Just ci) <- gets clientIndex |
394 ri <- clientRoomA |
394 rnc <- gets roomsClients |
395 inGame <- io $ room'sM rnc (isJust . gameInfo) ri |
395 ri <- clientRoomA |
|
396 inGame <- io $ do |
|
397 r <- room'sM rnc (isJust . gameInfo) ri |
|
398 c <- client'sM rnc isInGame ci |
|
399 return $ r && c |
396 chans <- othersChans |
400 chans <- othersChans |
397 mapM_ processAction $ |
401 mapM_ processAction $ |
398 ModifyRoom (\r -> r{ |
402 ModifyRoom (\r -> r{ |
399 teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r |
403 teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r |
400 , gameInfo = liftM (\g -> g{leftTeams = teamName : leftTeams g}) $ gameInfo r |
404 , gameInfo = liftM (\g -> g{leftTeams = teamName : leftTeams g}) $ gameInfo r |
402 : SendUpdateOnThisRoom |
406 : SendUpdateOnThisRoom |
403 : AnswerClients chans ["REMOVE_TEAM", teamName] |
407 : AnswerClients chans ["REMOVE_TEAM", teamName] |
404 : [SendTeamRemovalMessage teamName | inGame] |
408 : [SendTeamRemovalMessage teamName | inGame] |
405 |
409 |
406 |
410 |
407 processAction (RemoveClientTeams clId) = do |
411 processAction RemoveClientTeams = do |
|
412 (Just ci) <- gets clientIndex |
408 rnc <- gets roomsClients |
413 rnc <- gets roomsClients |
409 |
414 |
410 removeTeamActions <- io $ do |
415 removeTeamActions <- io $ do |
411 clNick <- client'sM rnc nick clId |
416 rId <- clientRoomM rnc ci |
412 rId <- clientRoomM rnc clId |
|
413 roomTeams <- room'sM rnc teams rId |
417 roomTeams <- room'sM rnc teams rId |
414 return . Prelude.map (RemoveTeam . teamname) . Prelude.filter (\t -> teamowner t == clNick) $ roomTeams |
418 return . Prelude.map (RemoveTeam . teamname) . Prelude.filter (\t -> teamownerId t == ci) $ roomTeams |
415 |
419 |
416 mapM_ processAction removeTeamActions |
420 mapM_ processAction removeTeamActions |
417 |
421 |
418 |
422 |
419 |
423 |