# HG changeset patch # User unc0rr # Date 1354739892 -14400 # Node ID d7cf4a9ce685d04ffba65b5d217b2007052d25ae # Parent d1a830c304c72476a77a8a5ab6abfed85cc32914 Command to delegate room to other player diff -r d1a830c304c7 -r d7cf4a9ce685 gameServer/Actions.hs --- a/gameServer/Actions.hs Thu Dec 06 00:24:20 2012 +0400 +++ b/gameServer/Actions.hs Thu Dec 06 00:38:12 2012 +0400 @@ -55,7 +55,7 @@ | BanNick B.ByteString NominalDiffTime B.ByteString | BanList | Unban B.ByteString - | ChangeMaster + | ChangeMaster (Maybe ClientIndex) | RemoveClientTeams ClientIndex | ModifyClient (ClientInfo -> ClientInfo) | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo) @@ -235,7 +235,7 @@ if master then if playersNum > 1 then - mapM_ processAction [ChangeMaster, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] + mapM_ processAction [ChangeMaster Nothing, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] else processAction RemoveRoom else @@ -251,12 +251,12 @@ moveClientToLobby rnc ci -processAction ChangeMaster = do +processAction (ChangeMaster delegateId)= do (Just ci) <- gets clientIndex proto <- client's clientProto ri <- clientRoomA rnc <- gets roomsClients - newMasterId <- liftM (last . filter (/= ci)) . io $ roomClientsIndicesM rnc ri + newMasterId <- liftM (\ids -> fromMaybe (last . filter (/= ci) $ ids) delegateId) . io $ roomClientsIndicesM rnc ri newMaster <- io $ client'sM rnc id newMasterId oldRoomName <- io $ room'sM rnc name ri oldMaster <- client's nick diff -r d1a830c304c7 -r d7cf4a9ce685 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Thu Dec 06 00:24:20 2012 +0400 +++ b/gameServer/HWProtoInRoomState.hs Thu Dec 06 00:38:12 2012 +0400 @@ -301,6 +301,16 @@ [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom] +handleCmd_inRoom ["DELEGATE", newAdmin] = do + (thisClientId, rnc) <- ask + maybeClientId <- clientByNick newAdmin + master <- liftM isMaster thisClient + let newAdminId = fromJust maybeClientId + let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId + return + [ChangeMaster (Just newAdminId) | master && isJust maybeClientId && (newAdminId /= thisClientId) && sameRoom] + + handleCmd_inRoom ["TEAMCHAT", msg] = do cl <- thisClient chans <- roomSameClanChans