author | unc0rr |
Fri, 28 Jan 2011 22:21:29 +0300 | |
branch | server_refactor |
changeset 4606 | 4c521c4ab2b6 |
parent 4597 | 31e042ab870c |
child 4616 | cc3485866b93 |
permissions | -rw-r--r-- |
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 | 2 |
module HWProtoLobbyState where |
3 |
||
4 |
import qualified Data.Map as Map |
|
5 |
import qualified Data.IntSet as IntSet |
|
1813 | 6 |
import qualified Data.Foldable as Foldable |
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 |
1804 | 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 |
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
|
10 |
import Control.Monad.Reader |
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
|
11 |
import qualified Data.ByteString.Char8 as B |
4597
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
12 |
import Control.DeepSeq |
1804 | 13 |
-------------------------------------- |
14 |
import CoreTypes |
|
15 |
import Actions |
|
16 |
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
|
17 |
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
|
18 |
import RoomsAndClients |
1804 | 19 |
|
4591 | 20 |
answerAllTeams cl = concatMap toAnswer |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
21 |
where |
4591 | 22 |
clChan = sendChan cl |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
23 |
toAnswer team = |
4591 | 24 |
[AnswerClients [clChan] $ teamToNet team, |
25 |
AnswerClients [clChan] ["TEAM_COLOR", teamname team, teamcolor team], |
|
26 |
AnswerClients [clChan] ["HH_NUM", teamname team, B.pack . show $ hhnum team]] |
|
27 |
||
1804 | 28 |
handleCmd_lobby :: CmdHandler |
29 |
||
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
|
30 |
|
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 |
handleCmd_lobby ["LIST"] = 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 |
(ci, irnc) <- ask |
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 |
let cl = irnc `client` ci |
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 |
rooms <- allRoomInfos |
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 |
let roomsInfoList = concatMap (roomInfo irnc) . filter (\r -> (roomProto r == clientProto cl) && not (isRestrictedJoins 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
|
36 |
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
|
37 |
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
|
38 |
roomInfo irnc room = [ |
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 |
showB $ gameinprogress room, |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
40 |
name room, |
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
|
41 |
showB $ playersIn room, |
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
|
42 |
showB $ length $ teams room, |
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
|
43 |
nick $ irnc `client` masterID room, |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
44 |
head (Map.findWithDefault ["+gen+"] "MAP" (params room)), |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
45 |
head (Map.findWithDefault ["Default"] "SCHEME" (params room)), |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
46 |
head (Map.findWithDefault ["Default"] "AMMO" (params room)) |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
47 |
] |
3501 | 48 |
|
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
|
49 |
|
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
|
50 |
handleCmd_lobby ["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
|
51 |
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
|
52 |
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
|
53 |
return [AnswerClients s ["CHAT", n, msg]] |
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 |
|
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
|
55 |
handleCmd_lobby ["CREATE_ROOM", newRoom, roomPassword] |
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 |
| illegalName newRoom = return [Warning "Illegal room name"] |
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
|
57 |
| 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
|
58 |
rs <- allRoomInfos |
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
|
59 |
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
|
60 |
return $ if isJust $ find (\room -> newRoom == name room) rs 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
|
61 |
[Warning "Room exists"] |
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 |
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
|
63 |
[ |
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 |
AddRoom newRoom roomPassword, |
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 |
AnswerClients [sendChan cl] ["NOT_READY", nick 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
|
66 |
] |
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
|
67 |
|
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
|
68 |
|
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
|
69 |
handleCmd_lobby ["CREATE_ROOM", newRoom] = |
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
|
70 |
handleCmd_lobby ["CREATE_ROOM", newRoom, ""] |
1804 | 71 |
|
3536 | 72 |
|
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
|
73 |
handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = 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
|
74 |
(ci, irnc) <- ask |
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
|
75 |
let ris = allRooms irnc |
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
|
76 |
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
|
77 |
let maybeRI = find (\ri -> roomName == name (irnc `room` ri)) ris |
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 |
let jRI = fromJust maybeRI |
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 |
let jRoom = irnc `room` jRI |
4597
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
80 |
let jRoomClients = map (client irnc) $ roomClients irnc jRI |
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
81 |
let nicks = map nick jRoomClients |
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
82 |
let chans = map sendChan (cl : jRoomClients) |
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
|
83 |
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
|
84 |
if isNothing maybeRI 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
|
85 |
[Warning "No such rooms"] |
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
|
86 |
else if isRestrictedJoins jRoom 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
|
87 |
[Warning "Joining 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
|
88 |
else if roomPassword /= password jRoom 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
|
89 |
[Warning "Wrong password"] |
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 |
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
|
91 |
[ |
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 |
MoveToRoom jRI, |
4597
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
93 |
AnswerClients [sendChan cl] $ "JOINED" : nicks, |
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
94 |
AnswerClients chans ["NOT_READY", 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
|
95 |
] |
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 |
++ (map (readynessMessage cl) jRoomClients) |
4587 | 97 |
++ (answerFullConfig cl $ params jRoom) |
4591 | 98 |
++ (answerTeams cl jRoom) |
4595 | 99 |
++ (watchRound cl jRoom) |
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
|
100 |
|
4587 | 101 |
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
|
102 |
readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c] |
3536 | 103 |
|
4587 | 104 |
toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs |
105 |
||
106 |
answerFullConfig cl params = map (toAnswer cl) (leftConfigPart ++ rightConfigPart) |
|
107 |
where |
|
108 |
(leftConfigPart, rightConfigPart) = partition (\(p, _) -> p /= "MAP") $ Map.toList params |
|
109 |
||
4591 | 110 |
answerTeams cl jRoom = let f = if gameinprogress jRoom then teamsAtStart else teams in answerAllTeams cl $ f jRoom |
111 |
||
4595 | 112 |
watchRound cl jRoom = if not $ gameinprogress jRoom then |
113 |
[] |
|
114 |
else |
|
115 |
[AnswerClients [sendChan cl] ["RUN_GAME"], |
|
116 |
AnswerClients [sendChan cl] $ "EM" : toEngineMsg "e$spectate 1" : Foldable.toList (roundMsgs jRoom)] |
|
117 |
||
3536 | 118 |
|
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
|
119 |
handleCmd_lobby ["JOIN_ROOM", roomName] = |
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 |
handleCmd_lobby ["JOIN_ROOM", roomName, ""] |
3425 | 121 |
|
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
|
122 |
{- |
2961
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
123 |
handleCmd_lobby clID clients rooms ["FOLLOW", asknick] = |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
124 |
if noSuchClient || roomID followClient == 0 then |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
125 |
[] |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
126 |
else |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
127 |
handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName] |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
128 |
where |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
129 |
maybeClient = Foldable.find (\cl -> asknick == nick cl) clients |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
130 |
noSuchClient = isNothing maybeClient |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
131 |
followClient = fromJust maybeClient |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
132 |
roomName = name $ rooms IntMap.! roomID followClient |
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
133 |
|
1862 | 134 |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
135 |
--------------------------- |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
136 |
-- Administrator's stuff -- |
1862 | 137 |
|
138 |
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
|
139 |
[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
|
140 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
141 |
client = clients IntMap.! clID |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
142 |
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
|
143 |
noSuchClient = isNothing maybeClient |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
144 |
kickID = clientUID $ fromJust maybeClient |
1866 | 145 |
|
146 |
||
147 |
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
|
148 |
if not $ isAdministrator client then |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
149 |
[] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
150 |
else |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
151 |
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
|
152 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
153 |
client = clients IntMap.! clID |
1862 | 154 |
|
1804 | 155 |
|
3283 | 156 |
|
157 |
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
|
158 |
[ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator client] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
159 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
160 |
client = clients IntMap.! clID |
1925 | 161 |
|
3283 | 162 |
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
|
163 |
[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
|
164 |
where |
b44b88908758
Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents:
2961
diff
changeset
|
165 |
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
|
166 |
|
3283 | 167 |
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
|
168 |
[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
|
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 |
readNum = maybeRead protoNum :: Maybe Word16 |
1925 | 172 |
|
3283 | 173 |
handleCmd_lobby clID clients rooms ["GET_SERVER_VAR"] = |
174 |
[SendServerVars | isAdministrator client] |
|
175 |
where |
|
176 |
client = clients IntMap.! clID |
|
177 |
||
178 |
||
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2150
diff
changeset
|
179 |
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
|
180 |
[ClearAccountsCache | isAdministrator client] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
181 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
182 |
client = clients IntMap.! clID |
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 |
-} |
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2150
diff
changeset
|
184 |
|
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2150
diff
changeset
|
185 |
|
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
|
186 |
handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"] |