author | koda |
Sun, 04 Apr 2010 19:51:53 +0000 | |
changeset 3305 | 91074496d5c9 |
parent 3283 | 18ee933a5864 |
child 3425 | ead2ed20dfd4 |
permissions | -rw-r--r-- |
1804 | 1 |
module HWProtoLobbyState where |
2 |
||
3 |
import qualified Data.Map as Map |
|
4 |
import qualified Data.IntMap as IntMap |
|
5 |
import qualified Data.IntSet as IntSet |
|
1813 | 6 |
import qualified Data.Foldable as Foldable |
1804 | 7 |
import Maybe |
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 |
1804 | 10 |
-------------------------------------- |
11 |
import CoreTypes |
|
12 |
import Actions |
|
13 |
import Utils |
|
14 |
||
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
15 |
answerAllTeams protocol teams = concatMap toAnswer teams |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
16 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
17 |
toAnswer team = |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
18 |
[AnswerThisClient $ teamToNet protocol team, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
19 |
AnswerThisClient ["TEAM_COLOR", teamname team, teamcolor team], |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
20 |
AnswerThisClient ["HH_NUM", teamname team, show $ hhnum team]] |
1804 | 21 |
|
22 |
handleCmd_lobby :: CmdHandler |
|
23 |
||
24 |
handleCmd_lobby clID clients rooms ["LIST"] = |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
25 |
[AnswerThisClient ("ROOMS" : roomsInfoList)] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
26 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
27 |
roomsInfoList = concatMap roomInfo sameProtoRooms |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
28 |
sameProtoRooms = filter (\r -> (roomProto r == protocol) && not (isRestrictedJoins r)) roomsList |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
29 |
roomsList = IntMap.elems rooms |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
30 |
protocol = clientProto client |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
31 |
client = clients IntMap.! clID |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
32 |
roomInfo room |
3277 | 33 |
| clientProto client < 28 = [ |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
34 |
name room, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
35 |
show (playersIn room) ++ "(" ++ show (length $ teams room) ++ ")", |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
36 |
show $ gameinprogress room |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
37 |
] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
38 |
| otherwise = [ |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
39 |
show $ gameinprogress room, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
40 |
name room, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
41 |
show $ playersIn room, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
42 |
show $ length $ teams room, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
43 |
nick $ clients IntMap.! (masterID room), |
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 |
] |
1862 | 48 |
|
1815 | 49 |
handleCmd_lobby clID clients _ ["CHAT", msg] = |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
50 |
[AnswerOthersInRoom ["CHAT", clientNick, msg]] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
51 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
52 |
clientNick = nick $ clients IntMap.! clID |
1804 | 53 |
|
1862 | 54 |
|
2352 | 55 |
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
|
56 |
| haveSameRoom = [Warning "Room exists"] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
57 |
| illegalName newRoom = [Warning "Illegal room name"] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
58 |
| otherwise = |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
59 |
[RoomRemoveThisClient "", -- leave lobby |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
60 |
AddRoom newRoom roomPassword, |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
61 |
AnswerThisClient ["NOT_READY", clientNick] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
62 |
] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
63 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
64 |
clientNick = nick $ clients IntMap.! clID |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
65 |
haveSameRoom = isJust $ find (\room -> newRoom == name room) $ IntMap.elems rooms |
1804 | 66 |
|
1862 | 67 |
|
1905 | 68 |
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
|
69 |
handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, ""] |
1804 | 70 |
|
1862 | 71 |
|
2352 | 72 |
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
|
73 |
| noSuchRoom = [Warning "No such room"] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
74 |
| isRestrictedJoins jRoom = [Warning "Joining restricted"] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
75 |
| roomPassword /= password jRoom = [Warning "Wrong password"] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
76 |
| otherwise = |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
77 |
[RoomRemoveThisClient "", -- leave lobby |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
78 |
RoomAddThisClient rID] -- join room |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
79 |
++ answerNicks |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
80 |
++ answerReady |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
81 |
++ [AnswerThisRoom ["NOT_READY", nick client]] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
82 |
++ answerFullConfig |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
83 |
++ answerTeams |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
84 |
++ watchRound |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
85 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
86 |
noSuchRoom = isNothing mbRoom |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
87 |
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
|
88 |
jRoom = fromJust mbRoom |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
89 |
rID = roomUID jRoom |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
90 |
client = clients IntMap.! clID |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
91 |
roomClientsIDs = IntSet.elems $ playersIDs jRoom |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
92 |
answerNicks = |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
93 |
[AnswerThisClient $ "JOINED" : |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
94 |
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
|
95 |
answerReady = map |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
96 |
((\ c -> |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
97 |
AnswerThisClient |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
98 |
[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
|
99 |
. (\ clID -> clients IntMap.! clID)) |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
100 |
roomClientsIDs |
1804 | 101 |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
102 |
toAnswer (paramName, paramStrs) = AnswerThisClient $ "CFG" : paramName : paramStrs |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
103 |
|
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
104 |
answerFullConfig = map toAnswer (leftConfigPart ++ rightConfigPart) |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
105 |
(leftConfigPart, rightConfigPart) = partition (\(p, _) -> p /= "MAP") (Map.toList $ params jRoom) |
1813 | 106 |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
107 |
watchRound = if not $ gameinprogress jRoom then |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
108 |
[] |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
109 |
else |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
110 |
[AnswerThisClient ["RUN_GAME"], |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
111 |
AnswerThisClient $ "EM" : toEngineMsg "e$spectate 1" : Foldable.toList (roundMsgs jRoom)] |
1813 | 112 |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
113 |
answerTeams = if gameinprogress jRoom then |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
114 |
answerAllTeams (clientProto client) (teamsAtStart jRoom) |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
115 |
else |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
116 |
answerAllTeams (clientProto client) (teams jRoom) |
1804 | 117 |
|
118 |
||
1905 | 119 |
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
|
120 |
handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName, ""] |
2961
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
121 |
|
3e057dfa601f
Fix "FOLLOW" command handler and place it into proper file
unc0rr
parents:
2867
diff
changeset
|
122 |
|
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 |
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2150
diff
changeset
|
183 |
|
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2150
diff
changeset
|
184 |
|
1804 | 185 |
handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"] |