gameServer/HWProtoInRoomState.hs
author nemo
Fri, 16 Sep 2011 15:26:02 -0400
changeset 5939 d4680c51b220
parent 5931 184057074257
child 5996 2c72fe81dd37
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
     1
{-# LANGUAGE OverloadedStrings #-}
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     2
module HWProtoInRoomState 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
4614
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
     5
import Data.Sequence((|>), empty)
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
     6
import Data.List
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
     7
import Data.Maybe
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
     8
import qualified Data.ByteString.Char8 as B
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
     9
import Control.Monad
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    10
import Control.Monad.Reader
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    11
--------------------------------------
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    12
import CoreTypes
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    13
import Actions
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    14
import Utils
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    15
import HandlerUtils
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    16
import RoomsAndClients
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    17
4989
4771fed9272e - Write server config into .ini file on change
unc0rr
parents: 4986
diff changeset
    18
handleCmd_inRoom :: CmdHandler
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    19
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    20
handleCmd_inRoom ["CHAT", msg] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    21
    n <- clientNick
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    22
    s <- roomOthersChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    23
    return [AnswerClients s ["CHAT", n, msg]]
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    24
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    25
handleCmd_inRoom ["PART"] = return [MoveToLobby "part"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    26
handleCmd_inRoom ["PART", msg] = return [MoveToLobby $ "part: " `B.append` msg]
3531
66c403badff6 Reimplement room creating
unC0Rr@gmail.com
parents: 3500
diff changeset
    27
1811
1b9e33623b7e Implement 'roundfinished' cmd on net server
unc0rr
parents: 1804
diff changeset
    28
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    29
handleCmd_inRoom ("CFG" : paramName : paramStrs)
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    30
    | null paramStrs = return [ProtocolError "Empty config entry"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    31
    | otherwise = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    32
        chans <- roomOthersChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    33
        cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    34
        if isMaster cl then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    35
           return [
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    36
                ModifyRoom f,
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    37
                AnswerClients chans ("CFG" : paramName : paramStrs)]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    38
            else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    39
            return [ProtocolError "Not room master"]
4941
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    40
    where
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    41
        f r = if paramName `Map.member` (mapParams r) then
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    42
                r{mapParams = Map.insert paramName (head paramStrs) (mapParams r)}
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    43
                else
90572c338e60 Fix for my last commit (which was all nonsense)
unc0rr
parents: 4932
diff changeset
    44
                r{params = Map.insert paramName paramStrs (params r)}
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
    45
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    46
handleCmd_inRoom ("ADD_TEAM" : tName : color : grave : fort : voicepack : flag : difStr : hhsInfo)
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    47
    | length hhsInfo /= 16 = return [ProtocolError "Corrupted hedgehogs info"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    48
    | otherwise = do
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    49
        (ci, _) <- ask
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    50
        rm <- thisRoom
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    51
        clNick <- clientNick
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    52
        clChan <- thisClientChans
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    53
        othChans <- roomOthersChans
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    54
        return $
5931
184057074257 - Allow 8 teams in game on 0.9.16-dev
unc0rr
parents: 5143
diff changeset
    55
            if not . null . drop (maxTeams rm - 1) $ teams rm then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    56
                [Warning "too many teams"]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    57
            else if canAddNumber rm <= 0 then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    58
                [Warning "too many hedgehogs"]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    59
            else if isJust $ findTeam rm then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    60
                [Warning "There's already a team with same name in the list"]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    61
            else if gameinprogress rm then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    62
                [Warning "round in progress"]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    63
            else if isRestrictedTeams rm then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    64
                [Warning "restricted"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    65
            else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    66
                [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r]}),
4986
33fe91b2bcbf Use Maybe for storing client's clan, allows less error-prone spectator checks
unc0rr
parents: 4975
diff changeset
    67
                ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just color}),
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    68
                AnswerClients clChan ["TEAM_ACCEPTED", tName],
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    69
                AnswerClients othChans $ teamToNet $ newTeam ci clNick rm,
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    70
                AnswerClients othChans ["TEAM_COLOR", tName, color]
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    71
                ]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    72
        where
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    73
        canAddNumber r = 48 - (sum . map hhnum $ teams r)
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    74
        findTeam = find (\t -> tName == teamname t) . teams
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    75
        newTeam ci clNick r = TeamInfo ci clNick tName color grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
5030
42746c5d4a80 Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents: 4989
diff changeset
    76
        dif = readInt_ difStr
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    77
        hhsList [] = []
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    78
        hhsList [_] = error "Hedgehogs list with odd elements number"
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    79
        hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    80
        newTeamHHNum r = min 4 (canAddNumber r)
5931
184057074257 - Allow 8 teams in game on 0.9.16-dev
unc0rr
parents: 5143
diff changeset
    81
        maxTeams r 
184057074257 - Allow 8 teams in game on 0.9.16-dev
unc0rr
parents: 5143
diff changeset
    82
            | roomProto r < 38 = 6
184057074257 - Allow 8 teams in game on 0.9.16-dev
unc0rr
parents: 5143
diff changeset
    83
            | otherwise = 8
184057074257 - Allow 8 teams in game on 0.9.16-dev
unc0rr
parents: 5143
diff changeset
    84
                
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    85
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    86
handleCmd_inRoom ["REMOVE_TEAM", tName] = do
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
    87
        (ci, _) <- ask
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    88
        r <- thisRoom
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    89
        clNick <- clientNick
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    90
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    91
        let maybeTeam = findTeam r
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    92
        let team = fromJust maybeTeam
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    93
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    94
        return $
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    95
            if isNothing $ findTeam r then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    96
                [Warning "REMOVE_TEAM: no such team"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    97
            else if clNick /= teamowner team then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    98
                [ProtocolError "Not team owner!"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
    99
            else
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   100
                [RemoveTeam tName,
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   101
                ModifyClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   102
                    (\c -> c{
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   103
                        teamsInGame = teamsInGame c - 1,
4989
4771fed9272e - Write server config into .ini file on change
unc0rr
parents: 4986
diff changeset
   104
                        clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci r
4771fed9272e - Write server config into .ini file on change
unc0rr
parents: 4986
diff changeset
   105
                    })
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   106
                ]
4568
f85243bf890e Ok. This should pull 0.9.14.1 server into default
nemo
parents: 4337
diff changeset
   107
    where
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   108
        anotherTeamClan ci = teamcolor . fromJust . find (\t -> teamownerId t == ci) . teams
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   109
        findTeam = find (\t -> tName == teamname t) . teams
3561
7f8e07e4a4e3 Reimplement REMOVE_TEAM
unc0rr
parents: 3555
diff changeset
   110
3568
ae89cf0735dc A bunch of reimplemented commands
unc0rr
parents: 3566
diff changeset
   111
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   112
handleCmd_inRoom ["HH_NUM", teamName, numberStr] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   113
    cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   114
    others <- roomOthersChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   115
    r <- thisRoom
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   116
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   117
    let maybeTeam = findTeam r
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   118
    let team = fromJust maybeTeam
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   119
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   120
    return $
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   121
        if not $ isMaster cl then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   122
            [ProtocolError "Not room master"]
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   123
        else if hhNumber < 1 || hhNumber > 8 || isNothing maybeTeam || hhNumber > canAddNumber r + hhnum team then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   124
            []
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   125
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   126
            [ModifyRoom $ modifyTeam team{hhnum = hhNumber},
5030
42746c5d4a80 Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents: 4989
diff changeset
   127
            AnswerClients others ["HH_NUM", teamName, showB hhNumber]]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   128
    where
5030
42746c5d4a80 Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents: 4989
diff changeset
   129
        hhNumber = readInt_ numberStr
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   130
        findTeam = find (\t -> teamName == teamname t) . teams
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   131
        canAddNumber = (-) 48 . sum . map hhnum . teams
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   132
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   133
3568
ae89cf0735dc A bunch of reimplemented commands
unc0rr
parents: 3566
diff changeset
   134
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   135
handleCmd_inRoom ["TEAM_COLOR", teamName, newColor] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   136
    cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   137
    others <- roomOthersChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   138
    r <- thisRoom
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   139
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   140
    let maybeTeam = findTeam r
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   141
    let team = fromJust maybeTeam
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   142
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   143
    return $
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   144
        if not $ isMaster cl then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   145
            [ProtocolError "Not room master"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   146
        else if isNothing maybeTeam then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   147
            []
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   148
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   149
            [ModifyRoom $ modifyTeam team{teamcolor = newColor},
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   150
            AnswerClients others ["TEAM_COLOR", teamName, newColor],
4986
33fe91b2bcbf Use Maybe for storing client's clan, allows less error-prone spectator checks
unc0rr
parents: 4975
diff changeset
   151
            ModifyClient2 (teamownerId team) (\c -> c{clientClan = Just newColor})]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   152
    where
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   153
        findTeam = find (\t -> teamName == teamname t) . teams
3568
ae89cf0735dc A bunch of reimplemented commands
unc0rr
parents: 3566
diff changeset
   154
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   155
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   156
handleCmd_inRoom ["TOGGLE_READY"] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   157
    cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   158
    chans <- roomClientsChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   159
    return [
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   160
        ModifyClient (\c -> c{isReady = not $ isReady cl}),
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   161
        ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}),
4942
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   162
        AnswerClients chans $ if clientProto cl < 38 then
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   163
                [if isReady cl then "NOT_READY" else "READY", nick cl]
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   164
                else
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   165
                ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   166
        ]
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   167
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   168
handleCmd_inRoom ["START_GAME"] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   169
    cl <- thisClient
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   170
    rm <- thisRoom
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   171
    chans <- roomClientsChans
3577
0ef6f5182a75 START_GAME command
unc0rr
parents: 3568
diff changeset
   172
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   173
    if isMaster cl && playersIn rm == readyPlayers rm && not (gameinprogress rm) then
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   174
        if enoughClans rm then
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   175
            return [
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   176
                ModifyRoom
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   177
                    (\r -> r{
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   178
                        gameinprogress = True,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   179
                        roundMsgs = empty,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   180
                        leftTeams = [],
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   181
                        teamsAtStart = teams r}
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   182
                    ),
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   183
                AnswerClients chans ["RUN_GAME"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   184
                ]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   185
            else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   186
            return [Warning "Less than two clans!"]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   187
        else
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   188
        return []
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   189
    where
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   190
        enoughClans = not . null . drop 1 . group . map teamcolor . teams
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   191
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   192
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   193
handleCmd_inRoom ["EM", msg] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   194
    cl <- thisClient
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   195
    rm <- thisRoom
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   196
    chans <- roomOthersChans
4931
da43c36a6e92 Don't accept EM message when the game isn't started
unc0rr
parents: 4917
diff changeset
   197
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   198
    if teamsInGame cl > 0 && gameinprogress rm && isLegal then
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   199
        return $ AnswerClients chans ["EM", msg] : [ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}) | not isKeepAlive]
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   200
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   201
        return []
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   202
    where
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   203
        (isLegal, isKeepAlive) = checkNetCmd msg
1804
4e78ad846fb6 New game server:
unc0rr
parents:
diff changeset
   204
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   205
4908
99d6797b7ff4 Frontend sends ROUNDFINISHED with information about whether the round was played till end (will be needed for stats)
unc0rr
parents: 4904
diff changeset
   206
handleCmd_inRoom ["ROUNDFINISHED", _] = do
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   207
    cl <- thisClient
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   208
    rm <- thisRoom
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   209
    chans <- roomClientsChans
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   210
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   211
    if isMaster cl && gameinprogress rm then
5143
649d87819682 Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents: 5098
diff changeset
   212
        return $ 
649d87819682 Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents: 5098
diff changeset
   213
            ModifyRoom
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   214
                (\r -> r{
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   215
                    gameinprogress = False,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   216
                    readyPlayers = 0,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   217
                    roundMsgs = empty,
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   218
                    leftTeams = [],
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   219
                    teamsAtStart = []}
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   220
                )
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   221
            : UnreadyRoomClients
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   222
            : answerRemovedTeams chans rm
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   223
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   224
        return []
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   225
    where
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   226
        answerRemovedTeams chans = map (\t -> AnswerClients chans ["REMOVE_TEAM", t]) . leftTeams
1811
1b9e33623b7e Implement 'roundfinished' cmd on net server
unc0rr
parents: 1804
diff changeset
   227
4942
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   228
-- compatibility with clients with protocol < 38
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   229
handleCmd_inRoom ["ROUNDFINISHED"] =
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   230
    handleCmd_inRoom ["ROUNDFINISHED", "1"]
1c85a8e6e11c Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
unc0rr
parents: 4941
diff changeset
   231
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   232
handleCmd_inRoom ["TOGGLE_RESTRICT_JOINS"] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   233
    cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   234
    return $
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   235
        if not $ isMaster cl then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   236
            [ProtocolError "Not room master"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   237
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   238
            [ModifyRoom (\r -> r{isRestrictedJoins = not $ isRestrictedJoins r})]
4568
f85243bf890e Ok. This should pull 0.9.14.1 server into default
nemo
parents: 4337
diff changeset
   239
1831
025348f05b9f Implement two more missing protocol commands
unc0rr
parents: 1818
diff changeset
   240
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   241
handleCmd_inRoom ["TOGGLE_RESTRICT_TEAMS"] = do
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   242
    cl <- thisClient
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   243
    return $
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   244
        if not $ isMaster cl then
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   245
            [ProtocolError "Not room master"]
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   246
        else
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   247
            [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})]
1879
bb114339eb4e Implement kick from room
unc0rr
parents: 1866
diff changeset
   248
1831
025348f05b9f Implement two more missing protocol commands
unc0rr
parents: 1818
diff changeset
   249
5098
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   250
handleCmd_inRoom ["ROOM_NAME", newName] = do
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   251
    cl <- thisClient
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   252
    rs <- allRoomInfos
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   253
    
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   254
    return $
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   255
        if not $ isMaster cl then
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   256
            [ProtocolError "Not room master"]
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   257
        else
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   258
        if isJust $ find (\r -> newName == name r) rs then
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   259
            [Warning "Room with such name already exists"]
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   260
        else
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   261
            [ModifyRoom (\r -> r{name = newName})]
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   262
cb9cf41a208c Allow to rename room
unc0rr
parents: 5030
diff changeset
   263
4614
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   264
handleCmd_inRoom ["KICK", kickNick] = do
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   265
    (thisClientId, rnc) <- ask
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   266
    maybeClientId <- clientByNick kickNick
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   267
    master <- liftM isMaster thisClient
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   268
    let kickId = fromJust maybeClientId
4932
f11d80bac7ed - Take into account hlint suggestions
unc0rr
parents: 4931
diff changeset
   269
    let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
4614
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   270
    return
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   271
        [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom]
1879
bb114339eb4e Implement kick from room
unc0rr
parents: 1866
diff changeset
   272
1831
025348f05b9f Implement two more missing protocol commands
unc0rr
parents: 1818
diff changeset
   273
4614
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   274
handleCmd_inRoom ["TEAMCHAT", msg] = do
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   275
    cl <- thisClient
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   276
    chans <- roomSameClanChans
26661bf28dd5 Reimplement some more protocol commands
unc0rr
parents: 4337
diff changeset
   277
    return [AnswerClients chans ["EM", engineMsg cl]]
2867
9be6693c78cb - Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents: 2747
diff changeset
   278
    where
5030
42746c5d4a80 Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents: 4989
diff changeset
   279
        engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"]
4568
f85243bf890e Ok. This should pull 0.9.14.1 server into default
nemo
parents: 4337
diff changeset
   280
4295
1f5604cd99be This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents: 4242
diff changeset
   281
handleCmd_inRoom _ = return [ProtocolError "Incorrect command (state: in room)"]