241 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), |
241 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), |
242 ModifyClient2 newMasterId (\c -> c{isMaster = True}), |
242 ModifyClient2 newMasterId (\c -> c{isMaster = True}), |
243 AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
243 AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
244 ] |
244 ] |
245 |
245 |
|
246 proto <- client's clientProto |
|
247 newRoom <- io $ room'sM rnc id ri |
|
248 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
|
249 processAction $ AnswerClients chans ("ROOM" : "ADD" : roomInfo (nick newMaster) newRoom) |
|
250 |
246 processAction (AddRoom roomName roomPassword) = do |
251 processAction (AddRoom roomName roomPassword) = do |
247 Just clId <- gets clientIndex |
252 Just clId <- gets clientIndex |
248 rnc <- gets roomsClients |
253 rnc <- gets roomsClients |
249 proto <- io $ client'sM rnc clientProto clId |
254 proto <- client's clientProto |
|
255 n <- client's nick |
250 |
256 |
251 let rm = newRoom{ |
257 let rm = newRoom{ |
252 masterID = clId, |
258 masterID = clId, |
253 name = roomName, |
259 name = roomName, |
254 password = roomPassword, |
260 password = roomPassword, |
257 |
263 |
258 rId <- io $ addRoom rnc rm |
264 rId <- io $ addRoom rnc rm |
259 |
265 |
260 processAction $ MoveToRoom rId |
266 processAction $ MoveToRoom rId |
261 |
267 |
262 chans <- liftM (map sendChan) $! roomClientsS lobbyId |
268 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
263 |
269 |
264 mapM_ processAction [ |
270 mapM_ processAction [ |
265 AnswerClients chans ["ROOM", "ADD", roomName] |
271 AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm) |
266 , ModifyClient (\cl -> cl{isMaster = True}) |
272 , ModifyClient (\cl -> cl{isMaster = True}) |
267 ] |
273 ] |
268 |
274 |
269 |
275 |
270 processAction RemoveRoom = do |
276 processAction RemoveRoom = do |
271 Just clId <- gets clientIndex |
277 Just clId <- gets clientIndex |
272 rnc <- gets roomsClients |
278 rnc <- gets roomsClients |
273 ri <- io $ clientRoomM rnc clId |
279 ri <- io $ clientRoomM rnc clId |
274 roomName <- io $ room'sM rnc name ri |
280 roomName <- io $ room'sM rnc name ri |
275 others <- othersChans |
281 others <- othersChans |
276 lobbyChans <- liftM (map sendChan) $! roomClientsS lobbyId |
282 proto <- client's clientProto |
|
283 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
277 |
284 |
278 mapM_ processAction [ |
285 mapM_ processAction [ |
279 AnswerClients lobbyChans ["ROOM", "DEL", roomName], |
286 AnswerClients chans ["ROOM", "DEL", roomName], |
280 AnswerClients others ["ROOMABANDONED", roomName] |
287 AnswerClients others ["ROOMABANDONED", roomName] |
281 ] |
288 ] |
282 |
289 |
283 io $ removeRoom rnc ri |
290 io $ removeRoom rnc ri |
284 |
291 |