--- 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
--- 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