gameServer/Actions.hs
changeset 7682 f6bfbe829008
parent 7668 4cb423f42105
child 7710 fd5bcbd698a5
equal deleted inserted replaced
7681:26978d581070 7682:f6bfbe829008
   242     ri <- clientRoomA
   242     ri <- clientRoomA
   243     rnc <- gets roomsClients
   243     rnc <- gets roomsClients
   244     newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
   244     newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
   245     newMaster <- io $ client'sM rnc id newMasterId
   245     newMaster <- io $ client'sM rnc id newMasterId
   246     oldRoomName <- io $ room'sM rnc name ri
   246     oldRoomName <- io $ room'sM rnc name ri
       
   247     oldMaster <- client's nick
   247     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
   248     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
   248     let newRoomName = nick newMaster
   249     let newRoomName = nick newMaster
   249     mapM_ processAction [
   250     mapM_ processAction [
   250         ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False}),
   251         ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False})
   251         ModifyClient2 newMasterId (\c -> c{isMaster = True}),
   252         , ModifyClient2 newMasterId (\c -> c{isMaster = True})
   252         AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"],
   253         , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
   253         AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
   254         , AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
       
   255         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster]
       
   256         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+h", nick newMaster]
   254         ]
   257         ]
   255 
   258 
   256     proto <- client's clientProto
   259     proto <- client's clientProto
   257     newRoom <- io $ room'sM rnc id ri
   260     newRoom <- io $ room'sM rnc id ri
   258     chans <- liftM (map sendChan) $! sameProtoClientsS proto
   261     chans <- liftM (map sendChan) $! sameProtoClientsS proto
   262 processAction (AddRoom roomName roomPassword) = do
   265 processAction (AddRoom roomName roomPassword) = do
   263     Just clId <- gets clientIndex
   266     Just clId <- gets clientIndex
   264     rnc <- gets roomsClients
   267     rnc <- gets roomsClients
   265     proto <- client's clientProto
   268     proto <- client's clientProto
   266     n <- client's nick
   269     n <- client's nick
       
   270     chan <- client's sendChan
   267 
   271 
   268     let rm = newRoom{
   272     let rm = newRoom{
   269             masterID = clId,
   273             masterID = clId,
   270             name = roomName,
   274             name = roomName,
   271             password = roomPassword,
   275             password = roomPassword,
   278 
   282 
   279     chans <- liftM (map sendChan) $! sameProtoClientsS proto
   283     chans <- liftM (map sendChan) $! sameProtoClientsS proto
   280 
   284 
   281     mapM_ processAction [
   285     mapM_ processAction [
   282         AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm)
   286         AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm)
       
   287         , AnswerClients [chan] ["CLIENT_FLAGS", "+h", n]
   283         , ModifyClient (\cl -> cl{isMaster = True})
   288         , ModifyClient (\cl -> cl{isMaster = True})
   284         ]
   289         ]
   285 
   290 
   286 
   291 
   287 processAction RemoveRoom = do
   292 processAction RemoveRoom = do