gameServer/HWProtoLobbyState.hs
author unc0rr
Sun, 06 Jun 2010 19:03:06 +0000
changeset 3501 a3159a410e5c
parent 3500 af8390d807d6
child 3502 ad38c653b7d9
permissions -rw-r--r--
Reimplement more core actions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3500
af8390d807d6 Use sockets instead of handles, use bytestrings instead of strings
unc0rr
parents: 3435
diff changeset
     1
{-# LANGUAGE OverloadedStrings #-}
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     2
module HWProtoLobbyState where
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     3
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     4
import qualified Data.Map as Map
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     5
import qualified Data.IntSet as IntSet
1813
cfe1481e0247 Removeteam action
unc0rr
parents: 1811
diff changeset
     6
import qualified Data.Foldable as Foldable
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     7
import Maybe
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     8
import Data.List
3260
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
     9
import Data.Word
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    10
import Control.Monad.Reader
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    11
import qualified Data.ByteString.Char8 as B
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    12
--------------------------------------
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    13
import CoreTypes
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    14
import Actions
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    15
import Utils
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    16
import HandlerUtils
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    17
import RoomsAndClients
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    18
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    19
{-answerAllTeams protocol teams = concatMap toAnswer teams
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    20
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    21
        toAnswer team =
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    22
            [AnswerThisClient $ teamToNet protocol team,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    23
            AnswerThisClient ["TEAM_COLOR", teamname team, teamcolor team],
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    24
            AnswerThisClient ["HH_NUM", teamname team, show $ hhnum team]]
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    25
-}
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    26
handleCmd_lobby :: CmdHandler
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    27
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    28
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    29
handleCmd_lobby ["LIST"] = do
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    30
    (ci, irnc) <- ask
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    31
    let cl = irnc `client` ci
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    32
    rooms <- allRoomInfos
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    33
    let roomsInfoList = concatMap (roomInfo irnc) . filter (\r -> (roomProto r == clientProto cl) && not (isRestrictedJoins r))
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    34
    return [AnswerClients [sendChan cl] ("ROOMS" : roomsInfoList rooms)]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    35
    where
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    36
        roomInfo irnc room
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    37
            | roomProto room < 28 = [
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    38
                name room,
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    39
                B.pack $ show (playersIn room) ++ "(" ++ show (length $ teams room) ++ ")",
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    40
                B.pack $ show $ gameinprogress room
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    41
                ]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    42
            | otherwise = [
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    43
                showB $ gameinprogress room,
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    44
                name room,
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    45
                showB $ playersIn room,
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    46
                showB $ length $ teams room,
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    47
                nick $ irnc `client` (masterID room),
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    48
                head (Map.findWithDefault ["+gen+"] "MAP" (params room)),
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    49
                head (Map.findWithDefault ["Default"] "SCHEME" (params room)),
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    50
                head (Map.findWithDefault ["Default"] "AMMO" (params room))
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    51
                ]
3501
a3159a410e5c Reimplement more core actions
unc0rr
parents: 3500
diff changeset
    52
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
    53
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    54
handleCmd_lobby ["CHAT", msg] = do
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    55
    n <- clientNick
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    56
    s <- roomOthersChans
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    57
    return [AnswerClients s ["CHAT", n, msg]]
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    58
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
    59
{-
2352
7eaf82cf0890 Fixes suggested by hlint tool
unc0rr
parents: 2155
diff changeset
    60
handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, roomPassword]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    61
    | haveSameRoom = [Warning "Room exists"]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    62
    | illegalName newRoom = [Warning "Illegal room name"]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    63
    | otherwise =
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    64
        [RoomRemoveThisClient "", -- leave lobby
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    65
        AddRoom newRoom roomPassword,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    66
        AnswerThisClient ["NOT_READY", clientNick]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    67
        ]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    68
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    69
        clientNick = nick $ clients IntMap.! clID
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    70
        haveSameRoom = isJust $ find (\room -> newRoom == name room) $ IntMap.elems rooms
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    71
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
    72
1905
b1ec8db513f2 - Use QCryptographicHash for md5
unc0rr
parents: 1871
diff changeset
    73
handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    74
    handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, ""]
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    75
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
    76
2352
7eaf82cf0890 Fixes suggested by hlint tool
unc0rr
parents: 2155
diff changeset
    77
handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName, roomPassword]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    78
    | noSuchRoom = [Warning "No such room"]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    79
    | isRestrictedJoins jRoom = [Warning "Joining restricted"]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    80
    | roomPassword /= password jRoom = [Warning "Wrong password"]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    81
    | otherwise =
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    82
        [RoomRemoveThisClient "", -- leave lobby
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    83
        RoomAddThisClient rID] -- join room
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    84
        ++ answerNicks
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    85
        ++ answerReady
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    86
        ++ [AnswerThisRoom ["NOT_READY", nick client]]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    87
        ++ answerFullConfig
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    88
        ++ answerTeams
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    89
        ++ watchRound
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    90
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    91
        noSuchRoom = isNothing mbRoom
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    92
        mbRoom = find (\r -> roomName == name r && roomProto r == clientProto client) $ IntMap.elems rooms
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    93
        jRoom = fromJust mbRoom
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    94
        rID = roomUID jRoom
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    95
        client = clients IntMap.! clID
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    96
        roomClientsIDs = IntSet.elems $ playersIDs jRoom
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    97
        answerNicks =
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    98
            [AnswerThisClient $ "JOINED" :
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
    99
            map (\clID -> nick $ clients IntMap.! clID) roomClientsIDs | playersIn jRoom /= 0]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   100
        answerReady = map
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   101
            ((\ c ->
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   102
                AnswerThisClient
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   103
                [if isReady c then "READY" else "NOT_READY", nick c])
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   104
            . (\ clID -> clients IntMap.! clID))
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   105
            roomClientsIDs
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   106
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   107
        toAnswer (paramName, paramStrs) = AnswerThisClient $ "CFG" : paramName : paramStrs
3425
ead2ed20dfd4 Start the server refactoring
unc0rr
parents: 3283
diff changeset
   108
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   109
        answerFullConfig = map toAnswer (leftConfigPart ++ rightConfigPart)
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   110
        (leftConfigPart, rightConfigPart) = partition (\(p, _) -> p /= "MAP") (Map.toList $ params jRoom)
1813
cfe1481e0247 Removeteam action
unc0rr
parents: 1811
diff changeset
   111
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   112
        watchRound = if not $ gameinprogress jRoom then
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   113
                    []
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   114
                else
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   115
                    [AnswerThisClient  ["RUN_GAME"],
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   116
                    AnswerThisClient $ "EM" : toEngineMsg "e$spectate 1" : Foldable.toList (roundMsgs jRoom)]
1813
cfe1481e0247 Removeteam action
unc0rr
parents: 1811
diff changeset
   117
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   118
        answerTeams = if gameinprogress jRoom then
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   119
                answerAllTeams (clientProto client) (teamsAtStart jRoom)
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   120
            else
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   121
                answerAllTeams (clientProto client) (teams jRoom)
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   122
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   123
1905
b1ec8db513f2 - Use QCryptographicHash for md5
unc0rr
parents: 1871
diff changeset
   124
handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   125
    handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName, ""]
3425
ead2ed20dfd4 Start the server refactoring
unc0rr
parents: 3283
diff changeset
   126
2961
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   127
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   128
handleCmd_lobby clID clients rooms ["FOLLOW", asknick] =
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   129
    if noSuchClient || roomID followClient == 0 then
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   130
        []
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   131
    else
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   132
        handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName]
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   133
    where
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   134
        maybeClient = Foldable.find (\cl -> asknick == nick cl) clients
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   135
        noSuchClient = isNothing maybeClient
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   136
        followClient = fromJust maybeClient
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   137
        roomName = name $ rooms IntMap.! roomID followClient
3e057dfa601f Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents: 2867
diff changeset
   138
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
   139
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   140
    ---------------------------
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   141
    -- Administrator's stuff --
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
   142
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
   143
handleCmd_lobby clID clients rooms ["KICK", kickNick] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   144
        [KickClient kickID | isAdministrator client && (not noSuchClient) && kickID /= clID]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   145
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   146
        client = clients IntMap.! clID
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   147
        maybeClient = Foldable.find (\cl -> kickNick == nick cl) clients
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   148
        noSuchClient = isNothing maybeClient
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   149
        kickID = clientUID $ fromJust maybeClient
1866
36aa0ca6e8af Cut the length of most used net packet
unc0rr
parents: 1862
diff changeset
   150
36aa0ca6e8af Cut the length of most used net packet
unc0rr
parents: 1862
diff changeset
   151
36aa0ca6e8af Cut the length of most used net packet
unc0rr
parents: 1862
diff changeset
   152
handleCmd_lobby clID clients rooms ["BAN", banNick] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   153
    if not $ isAdministrator client then
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   154
        []
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   155
    else
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   156
        BanClient banNick : handleCmd_lobby clID clients rooms ["KICK", banNick]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   157
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   158
        client = clients IntMap.! clID
1862
7f303aa066da Implement kick from server by administrator
unc0rr
parents: 1815
diff changeset
   159
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   160
3283
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   161
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   162
handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "MOTD_NEW", newMessage] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   163
        [ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator client]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   164
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   165
        client = clients IntMap.! clID
1925
ec923e56c444 Allow admin to set server's motd
unc0rr
parents: 1905
diff changeset
   166
3283
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   167
handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "MOTD_OLD", newMessage] =
3260
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   168
        [ModifyServerInfo (\si -> si{serverMessageForOldVersions = newMessage}) | isAdministrator client]
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   169
    where
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   170
        client = clients IntMap.! clID
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   171
3283
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   172
handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "LATEST_PROTO", protoNum] =
3260
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   173
    [ModifyServerInfo (\si -> si{latestReleaseVersion = fromJust readNum}) | isAdministrator client && isJust readNum]
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   174
    where
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   175
        client = clients IntMap.! clID
b44b88908758 Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents: 2961
diff changeset
   176
        readNum = maybeRead protoNum :: Maybe Word16
1925
ec923e56c444 Allow admin to set server's motd
unc0rr
parents: 1905
diff changeset
   177
3283
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   178
handleCmd_lobby clID clients rooms ["GET_SERVER_VAR"] =
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   179
    [SendServerVars | isAdministrator client]
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   180
    where
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   181
        client = clients IntMap.! clID
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   182
18ee933a5864 Some stuff for game server administration task
unc0rr
parents: 3277
diff changeset
   183
2155
d897222d3339 Implement ability for server admin to clear accounts cache
unc0rr
parents: 2150
diff changeset
   184
handleCmd_lobby clID clients rooms ["CLEAR_ACCOUNTS_CACHE"] =
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   185
        [ClearAccountsCache | isAdministrator client]
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   186
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2408
diff changeset
   187
        client = clients IntMap.! clID
2155
d897222d3339 Implement ability for server admin to clear accounts cache
unc0rr
parents: 2150
diff changeset
   188
d897222d3339 Implement ability for server admin to clear accounts cache
unc0rr
parents: 2150
diff changeset
   189
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   190
handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"]
3435
4e4f88a7bdf2 Some more steps in refactoring
unc0rr
parents: 3425
diff changeset
   191
-}