Change room name if room admin is kicked
authorunc0rr
Thu, 06 Dec 2012 00:24:20 +0400
changeset 8245 d1a830c304c7
parent 8243 92a430205796
child 8247 d7cf4a9ce685
Change room name if room admin is kicked
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/NetRoutines.hs
--- a/gameServer/Actions.hs	Thu Dec 06 00:14:40 2012 +0400
+++ b/gameServer/Actions.hs	Thu Dec 06 00:24:20 2012 +0400
@@ -260,8 +260,9 @@
     newMaster <- io $ client'sM rnc id newMasterId
     oldRoomName <- io $ room'sM rnc name ri
     oldMaster <- client's nick
+    kicked <- client's isKickedFromServer
     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
-    let newRoomName = if proto < 42 then nick newMaster else oldRoomName
+    let newRoomName = if (proto < 42) || kicked then nick newMaster else oldRoomName
     mapM_ processAction [
         ModifyRoom (\r -> r{masterID = newMasterId
                 , name = newRoomName
@@ -271,7 +272,6 @@
                 , readyPlayers = if isReady newMaster then readyPlayers r else readyPlayers r + 1})
         , ModifyClient2 newMasterId (\c -> c{isMaster = True, isReady = True})
         , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
-        , AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster]
         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+hr", nick newMaster]
         ]
@@ -487,8 +487,9 @@
     clHost <- client's host
     currentTime <- io getCurrentTime
     mapM_ processAction [
-        AddIP2Bans clHost "60 seconds cooldown after kick" (addUTCTime 60 currentTime),
-        ByeClient "Kicked"
+        AddIP2Bans clHost "60 seconds cooldown after kick" (addUTCTime 60 currentTime)
+        , ModifyClient (\c -> c{isKickedFromServer = True})
+        , ByeClient "Kicked"
         ]
 
 
@@ -502,12 +503,14 @@
         , KickClient banId
         ]
 
+
 processAction (BanIP ip seconds reason) = do
     currentTime <- io getCurrentTime
     let msg = B.concat ["Ban for ", B.pack . show $ seconds, " (", reason, ")"]
     processAction $
         AddIP2Bans ip msg (addUTCTime seconds currentTime)
 
+
 processAction (BanNick n seconds reason) = do
     currentTime <- io getCurrentTime
     let msg = 
@@ -518,6 +521,7 @@
     processAction $
         AddNick2Bans n msg (addUTCTime seconds currentTime)
 
+
 processAction BanList = do
     time <- io $ getCurrentTime
     ch <- client's sendChan
@@ -528,12 +532,14 @@
         ban2Str time (BanByIP b r t) = ["I", b, r, B.pack . show $ t `diffUTCTime` time]
         ban2Str time (BanByNick b r t) = ["N", b, r, B.pack . show $ t `diffUTCTime` time]
 
+
 processAction (Unban entry) = do
     processAction $ ModifyServerInfo (\s -> s{bans = filter (not . f) $ bans s})
     where
         f (BanByIP bip _ _) = bip == entry
         f (BanByNick bn _ _) = bn == entry
 
+
 processAction (KickRoomClient kickId) = do
     modify (\s -> s{clientIndex = Just kickId})
     ch <- client's sendChan
--- a/gameServer/CoreTypes.hs	Thu Dec 06 00:14:40 2012 +0400
+++ b/gameServer/CoreTypes.hs	Thu Dec 06 00:24:20 2012 +0400
@@ -36,6 +36,7 @@
         isReady :: !Bool,
         isInGame :: Bool,
         isAdministrator :: Bool,
+        isKickedFromServer :: Bool,
         clientClan :: Maybe B.ByteString,
         teamsInGame :: Word
     }
--- a/gameServer/NetRoutines.hs	Thu Dec 06 00:14:40 2012 +0400
+++ b/gameServer/NetRoutines.hs	Thu Dec 06 00:24:20 2012 +0400
@@ -41,6 +41,7 @@
                     False
                     False
                     False
+                    False
                     Nothing
                     0
                     )