5184
|
1 |
{-# LANGUAGE OverloadedStrings #-}
|
|
2 |
module Actions where
|
|
3 |
|
|
4 |
import Control.Concurrent
|
|
5 |
import qualified Data.Set as Set
|
|
6 |
import qualified Data.Sequence as Seq
|
|
7 |
import qualified Data.List as L
|
|
8 |
import qualified Control.Exception as Exception
|
|
9 |
import System.Log.Logger
|
|
10 |
import Control.Monad
|
|
11 |
import Data.Time
|
|
12 |
import Data.Maybe
|
|
13 |
import Control.Monad.Reader
|
|
14 |
import Control.Monad.State.Strict
|
|
15 |
import qualified Data.ByteString.Char8 as B
|
|
16 |
import Control.DeepSeq
|
|
17 |
import Data.Unique
|
|
18 |
import Control.Arrow
|
|
19 |
import Control.Exception
|
|
20 |
import OfficialServer.GameReplayStore
|
|
21 |
-----------------------------
|
|
22 |
import CoreTypes
|
|
23 |
import Utils
|
|
24 |
import ClientIO
|
|
25 |
import ServerState
|
|
26 |
import Consts
|
|
27 |
import ConfigFile
|
|
28 |
|
|
29 |
data Action =
|
|
30 |
AnswerClients ![ClientChan] ![B.ByteString]
|
|
31 |
| SendServerMessage
|
|
32 |
| SendServerVars
|
|
33 |
| MoveToRoom RoomIndex
|
|
34 |
| MoveToLobby B.ByteString
|
|
35 |
| RemoveTeam B.ByteString
|
|
36 |
| RemoveRoom
|
|
37 |
| UnreadyRoomClients
|
|
38 |
| JoinLobby
|
|
39 |
| ProtocolError B.ByteString
|
|
40 |
| Warning B.ByteString
|
|
41 |
| NoticeMessage Notice
|
|
42 |
| ByeClient B.ByteString
|
|
43 |
| KickClient ClientIndex
|
|
44 |
| KickRoomClient ClientIndex
|
|
45 |
| BanClient NominalDiffTime B.ByteString ClientIndex
|
|
46 |
| ChangeMaster
|
|
47 |
| RemoveClientTeams ClientIndex
|
|
48 |
| ModifyClient (ClientInfo -> ClientInfo)
|
|
49 |
| ModifyClient2 ClientIndex (ClientInfo -> ClientInfo)
|
|
50 |
| ModifyRoom (RoomInfo -> RoomInfo)
|
|
51 |
| ModifyServerInfo (ServerInfo -> ServerInfo)
|
|
52 |
| AddRoom B.ByteString B.ByteString
|
|
53 |
| CheckRegistered
|
|
54 |
| ClearAccountsCache
|
|
55 |
| ProcessAccountInfo AccountInfo
|
|
56 |
| AddClient ClientInfo
|
|
57 |
| DeleteClient ClientIndex
|
|
58 |
| PingAll
|
|
59 |
| StatsAction
|
|
60 |
| RestartServer Bool
|
|
61 |
| AddNick2Bans B.ByteString B.ByteString UTCTime
|
|
62 |
| AddIP2Bans B.ByteString B.ByteString UTCTime
|
|
63 |
| CheckBanned
|
|
64 |
| SaveReplay
|
|
65 |
|
|
66 |
|
|
67 |
type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
|
|
68 |
|
|
69 |
instance NFData Action where
|
|
70 |
rnf (AnswerClients chans msg) = chans `deepseq` msg `deepseq` ()
|
|
71 |
rnf a = a `seq` ()
|
|
72 |
|
|
73 |
instance NFData B.ByteString
|
|
74 |
instance NFData (Chan a)
|
|
75 |
|
|
76 |
|
|
77 |
othersChans :: StateT ServerState IO [ClientChan]
|
|
78 |
othersChans = do
|
|
79 |
cl <- client's id
|
|
80 |
ri <- clientRoomA
|
|
81 |
liftM (map sendChan . filter (/= cl)) $ roomClientsS ri
|
|
82 |
|
|
83 |
processAction :: Action -> StateT ServerState IO ()
|
|
84 |
|
|
85 |
|
|
86 |
processAction (AnswerClients chans msg) =
|
|
87 |
io $ mapM_ (`writeChan` (msg `deepseq` msg)) (chans `deepseq` chans)
|
|
88 |
|
|
89 |
|
|
90 |
processAction SendServerMessage = do
|
|
91 |
chan <- client's sendChan
|
|
92 |
protonum <- client's clientProto
|
|
93 |
si <- liftM serverInfo get
|
|
94 |
let message = if protonum < latestReleaseVersion si then
|
|
95 |
serverMessageForOldVersions si
|
|
96 |
else
|
|
97 |
serverMessage si
|
|
98 |
processAction $ AnswerClients [chan] ["SERVER_MESSAGE", message]
|
|
99 |
|
|
100 |
|
|
101 |
processAction SendServerVars = do
|
|
102 |
chan <- client's sendChan
|
|
103 |
si <- gets serverInfo
|
|
104 |
io $ writeChan chan ("SERVER_VARS" : vars si)
|
|
105 |
where
|
|
106 |
vars si = [
|
|
107 |
"MOTD_NEW", serverMessage si,
|
|
108 |
"MOTD_OLD", serverMessageForOldVersions si,
|
|
109 |
"LATEST_PROTO", showB $ latestReleaseVersion si
|
|
110 |
]
|
|
111 |
|
|
112 |
|
|
113 |
processAction (ProtocolError msg) = do
|
|
114 |
chan <- client's sendChan
|
|
115 |
processAction $ AnswerClients [chan] ["ERROR", msg]
|
|
116 |
|
|
117 |
|
|
118 |
processAction (Warning msg) = do
|
|
119 |
chan <- client's sendChan
|
|
120 |
processAction $ AnswerClients [chan] ["WARNING", msg]
|
|
121 |
|
|
122 |
processAction (NoticeMessage n) = do
|
|
123 |
chan <- client's sendChan
|
|
124 |
processAction $ AnswerClients [chan] ["NOTICE", showB . fromEnum $ n]
|
|
125 |
|
|
126 |
processAction (ByeClient msg) = do
|
|
127 |
(Just ci) <- gets clientIndex
|
|
128 |
ri <- clientRoomA
|
|
129 |
|
|
130 |
chan <- client's sendChan
|
|
131 |
clNick <- client's nick
|
|
132 |
loggedIn <- client's logonPassed
|
|
133 |
|
|
134 |
when (ri /= lobbyId) $ do
|
|
135 |
processAction $ MoveToLobby ("quit: " `B.append` msg)
|
|
136 |
return ()
|
|
137 |
|
|
138 |
clientsChans <- liftM (Prelude.map sendChan . Prelude.filter logonPassed) $! allClientsS
|
|
139 |
io $
|
|
140 |
infoM "Clients" (show ci ++ " quits: " ++ B.unpack msg)
|
|
141 |
|
|
142 |
processAction $ AnswerClients [chan] ["BYE", msg]
|
|
143 |
when loggedIn $ processAction $ AnswerClients clientsChans ["LOBBY:LEFT", clNick, msg]
|
|
144 |
|
|
145 |
s <- get
|
|
146 |
put $! s{removedClients = ci `Set.insert` removedClients s}
|
|
147 |
|
|
148 |
processAction (DeleteClient ci) = do
|
|
149 |
io $ debugM "Clients" $ "DeleteClient: " ++ show ci
|
|
150 |
|
|
151 |
rnc <- gets roomsClients
|
|
152 |
io $ removeClient rnc ci
|
|
153 |
|
|
154 |
s <- get
|
|
155 |
put $! s{removedClients = ci `Set.delete` removedClients s}
|
|
156 |
|
|
157 |
processAction (ModifyClient f) = do
|
|
158 |
(Just ci) <- gets clientIndex
|
|
159 |
rnc <- gets roomsClients
|
|
160 |
io $ modifyClient rnc f ci
|
|
161 |
return ()
|
|
162 |
|
|
163 |
processAction (ModifyClient2 ci f) = do
|
|
164 |
rnc <- gets roomsClients
|
|
165 |
io $ modifyClient rnc f ci
|
|
166 |
return ()
|
|
167 |
|
|
168 |
|
|
169 |
processAction (ModifyRoom f) = do
|
|
170 |
rnc <- gets roomsClients
|
|
171 |
ri <- clientRoomA
|
|
172 |
io $ modifyRoom rnc f ri
|
|
173 |
return ()
|
|
174 |
|
|
175 |
|
|
176 |
processAction (ModifyServerInfo f) = do
|
|
177 |
modify (\s -> s{serverInfo = f $ serverInfo s})
|
|
178 |
si <- gets serverInfo
|
|
179 |
io $ writeServerConfig si
|
|
180 |
|
|
181 |
|
|
182 |
processAction (MoveToRoom ri) = do
|
|
183 |
(Just ci) <- gets clientIndex
|
|
184 |
rnc <- gets roomsClients
|
|
185 |
|
|
186 |
io $ do
|
|
187 |
modifyClient rnc (\cl -> cl{teamsInGame = 0, isReady = False, isMaster = False}) ci
|
|
188 |
modifyRoom rnc (\r -> r{playersIn = playersIn r + 1}) ri
|
|
189 |
moveClientToRoom rnc ri ci
|
|
190 |
|
|
191 |
chans <- liftM (map sendChan) $ roomClientsS ri
|
|
192 |
clNick <- client's nick
|
|
193 |
|
|
194 |
processAction $ AnswerClients chans ["JOINED", clNick]
|
|
195 |
|
|
196 |
|
|
197 |
processAction (MoveToLobby msg) = do
|
|
198 |
(Just ci) <- gets clientIndex
|
|
199 |
ri <- clientRoomA
|
|
200 |
rnc <- gets roomsClients
|
|
201 |
(gameProgress, playersNum) <- io $ room'sM rnc (gameinprogress &&& playersIn) ri
|
|
202 |
ready <- client's isReady
|
|
203 |
master <- client's isMaster
|
|
204 |
-- client <- client's id
|
|
205 |
clNick <- client's nick
|
|
206 |
chans <- othersChans
|
|
207 |
|
|
208 |
if master then
|
|
209 |
if gameProgress && playersNum > 1 then
|
|
210 |
mapM_ processAction [ChangeMaster, AnswerClients chans ["LEFT", clNick, msg], NoticeMessage AdminLeft, RemoveClientTeams ci]
|
|
211 |
else
|
|
212 |
processAction RemoveRoom
|
|
213 |
else
|
|
214 |
mapM_ processAction [AnswerClients chans ["LEFT", clNick, msg], RemoveClientTeams ci]
|
|
215 |
|
|
216 |
-- when not removing room
|
|
217 |
when (not master || (gameProgress && playersNum > 1)) . io $ do
|
|
218 |
modifyRoom rnc (\r -> r{
|
|
219 |
playersIn = playersIn r - 1,
|
|
220 |
readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r
|
|
221 |
}) ri
|
|
222 |
moveClientToLobby rnc ci
|
|
223 |
|
|
224 |
processAction ChangeMaster = do
|
|
225 |
(Just ci) <- gets clientIndex
|
|
226 |
ri <- clientRoomA
|
|
227 |
rnc <- gets roomsClients
|
|
228 |
newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
|
|
229 |
newMaster <- io $ client'sM rnc id newMasterId
|
|
230 |
let newRoomName = nick newMaster
|
|
231 |
mapM_ processAction [
|
|
232 |
ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}),
|
|
233 |
ModifyClient2 newMasterId (\c -> c{isMaster = True}),
|
|
234 |
AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
|
|
235 |
]
|
|
236 |
|
|
237 |
processAction (AddRoom roomName roomPassword) = do
|
|
238 |
Just clId <- gets clientIndex
|
|
239 |
rnc <- gets roomsClients
|
|
240 |
proto <- io $ client'sM rnc clientProto clId
|
|
241 |
|
|
242 |
let rm = newRoom{
|
|
243 |
masterID = clId,
|
|
244 |
name = roomName,
|
|
245 |
password = roomPassword,
|
|
246 |
roomProto = proto
|
|
247 |
}
|
|
248 |
|
|
249 |
rId <- io $ addRoom rnc rm
|
|
250 |
|
|
251 |
processAction $ MoveToRoom rId
|
|
252 |
|
|
253 |
chans <- liftM (map sendChan) $! roomClientsS lobbyId
|
|
254 |
|
|
255 |
mapM_ processAction [
|
|
256 |
AnswerClients chans ["ROOM", "ADD", roomName]
|
|
257 |
, ModifyClient (\cl -> cl{isMaster = True})
|
|
258 |
]
|
|
259 |
|
|
260 |
|
|
261 |
processAction RemoveRoom = do
|
|
262 |
Just clId <- gets clientIndex
|
|
263 |
rnc <- gets roomsClients
|
|
264 |
ri <- io $ clientRoomM rnc clId
|
|
265 |
roomName <- io $ room'sM rnc name ri
|
|
266 |
others <- othersChans
|
|
267 |
lobbyChans <- liftM (map sendChan) $! roomClientsS lobbyId
|
|
268 |
|
|
269 |
mapM_ processAction [
|
|
270 |
AnswerClients lobbyChans ["ROOM", "DEL", roomName],
|
|
271 |
AnswerClients others ["ROOMABANDONED", roomName]
|
|
272 |
]
|
|
273 |
|
|
274 |
io $ removeRoom rnc ri
|
|
275 |
|
|
276 |
|
|
277 |
processAction (UnreadyRoomClients) = do
|
|
278 |
rnc <- gets roomsClients
|
|
279 |
ri <- clientRoomA
|
|
280 |
roomPlayers <- roomClientsS ri
|
|
281 |
roomClIDs <- io $ roomClientsIndicesM rnc ri
|
|
282 |
pr <- client's clientProto
|
|
283 |
processAction $ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
|
|
284 |
io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
|
|
285 |
processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
|
|
286 |
where
|
|
287 |
notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks
|
|
288 |
|
|
289 |
|
|
290 |
processAction (RemoveTeam teamName) = do
|
|
291 |
rnc <- gets roomsClients
|
|
292 |
ri <- clientRoomA
|
|
293 |
inGame <- io $ room'sM rnc gameinprogress ri
|
|
294 |
chans <- othersChans
|
|
295 |
if not $ inGame then
|
|
296 |
mapM_ processAction [
|
|
297 |
AnswerClients chans ["REMOVE_TEAM", teamName],
|
|
298 |
ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r})
|
|
299 |
]
|
|
300 |
else
|
|
301 |
mapM_ processAction [
|
|
302 |
AnswerClients chans ["EM", rmTeamMsg],
|
|
303 |
ModifyRoom (\r -> r{
|
|
304 |
teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r,
|
|
305 |
leftTeams = teamName : leftTeams r,
|
|
306 |
roundMsgs = roundMsgs r Seq.|> rmTeamMsg
|
|
307 |
})
|
|
308 |
]
|
|
309 |
where
|
|
310 |
rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName
|
|
311 |
|
|
312 |
|
|
313 |
processAction (RemoveClientTeams clId) = do
|
|
314 |
rnc <- gets roomsClients
|
|
315 |
|
|
316 |
removeTeamActions <- io $ do
|
|
317 |
clNick <- client'sM rnc nick clId
|
|
318 |
rId <- clientRoomM rnc clId
|
|
319 |
roomTeams <- room'sM rnc teams rId
|
|
320 |
return . Prelude.map (RemoveTeam . teamname) . Prelude.filter (\t -> teamowner t == clNick) $ roomTeams
|
|
321 |
|
|
322 |
mapM_ processAction removeTeamActions
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
processAction CheckRegistered = do
|
|
327 |
(Just ci) <- gets clientIndex
|
|
328 |
n <- client's nick
|
|
329 |
h <- client's host
|
|
330 |
p <- client's clientProto
|
|
331 |
uid <- client's clUID
|
|
332 |
haveSameNick <- liftM (not . null . tail . filter (\c -> nick c == n)) allClientsS
|
|
333 |
if haveSameNick then
|
|
334 |
if p < 38 then
|
|
335 |
mapM_ processAction [ByeClient "Nickname is already in use", removeNick]
|
|
336 |
else
|
|
337 |
mapM_ processAction [NoticeMessage NickAlreadyInUse, removeNick]
|
|
338 |
else
|
|
339 |
do
|
|
340 |
db <- gets (dbQueries . serverInfo)
|
|
341 |
io $ writeChan db $ CheckAccount ci (hashUnique uid) n h
|
|
342 |
return ()
|
|
343 |
where
|
|
344 |
removeNick = ModifyClient (\c -> c{nick = ""})
|
|
345 |
|
|
346 |
|
|
347 |
processAction ClearAccountsCache = do
|
|
348 |
dbq <- gets (dbQueries . serverInfo)
|
|
349 |
io $ writeChan dbq ClearCache
|
|
350 |
return ()
|
|
351 |
|
|
352 |
|
|
353 |
processAction (ProcessAccountInfo info) =
|
|
354 |
case info of
|
|
355 |
HasAccount passwd isAdmin -> do
|
|
356 |
chan <- client's sendChan
|
|
357 |
mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = passwd, isAdministrator = isAdmin})]
|
|
358 |
Guest ->
|
|
359 |
processAction JoinLobby
|
|
360 |
Admin -> do
|
|
361 |
mapM_ processAction [ModifyClient (\cl -> cl{isAdministrator = True}), JoinLobby]
|
|
362 |
chan <- client's sendChan
|
|
363 |
processAction $ AnswerClients [chan] ["ADMIN_ACCESS"]
|
|
364 |
|
|
365 |
|
|
366 |
processAction JoinLobby = do
|
|
367 |
chan <- client's sendChan
|
|
368 |
clientNick <- client's nick
|
|
369 |
(lobbyNicks, clientsChans) <- liftM (unzip . Prelude.map (nick &&& sendChan) . Prelude.filter logonPassed) $! allClientsS
|
|
370 |
mapM_ processAction $
|
|
371 |
AnswerClients clientsChans ["LOBBY:JOINED", clientNick]
|
|
372 |
: AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
|
|
373 |
: [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
|
|
374 |
|
|
375 |
|
|
376 |
processAction (KickClient kickId) = do
|
|
377 |
modify (\s -> s{clientIndex = Just kickId})
|
|
378 |
processAction $ ByeClient "Kicked"
|
|
379 |
|
|
380 |
|
|
381 |
processAction (BanClient seconds reason banId) = do
|
|
382 |
modify (\s -> s{clientIndex = Just banId})
|
|
383 |
clHost <- client's host
|
|
384 |
currentTime <- io getCurrentTime
|
|
385 |
let msg = B.concat ["Ban for ", B.pack . show $ seconds, "seconds (", reason, ")"]
|
|
386 |
mapM_ processAction [
|
|
387 |
AddIP2Bans clHost msg (addUTCTime seconds currentTime)
|
|
388 |
, KickClient banId
|
|
389 |
]
|
|
390 |
|
|
391 |
|
|
392 |
processAction (KickRoomClient kickId) = do
|
|
393 |
modify (\s -> s{clientIndex = Just kickId})
|
|
394 |
ch <- client's sendChan
|
|
395 |
mapM_ processAction [AnswerClients [ch] ["KICKED"], MoveToLobby "kicked"]
|
|
396 |
|
|
397 |
|
|
398 |
processAction (AddClient cl) = do
|
|
399 |
rnc <- gets roomsClients
|
|
400 |
si <- gets serverInfo
|
|
401 |
newClId <- io $ do
|
|
402 |
ci <- addClient rnc cl
|
|
403 |
_ <- Exception.mask (forkIO . clientRecvLoop (clientSocket cl) (coreChan si) (sendChan cl) ci)
|
|
404 |
|
|
405 |
infoM "Clients" (show ci ++ ": New client. Time: " ++ show (connectTime cl))
|
|
406 |
|
|
407 |
return ci
|
|
408 |
|
|
409 |
modify (\s -> s{clientIndex = Just newClId})
|
|
410 |
mapM_ processAction
|
|
411 |
[
|
|
412 |
AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
|
|
413 |
, CheckBanned
|
|
414 |
, AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl)
|
|
415 |
]
|
|
416 |
|
|
417 |
|
|
418 |
processAction (AddNick2Bans n reason expiring) = do
|
|
419 |
processAction $ ModifyServerInfo (\s -> s{bans = BanByNick n reason expiring : bans s})
|
|
420 |
|
|
421 |
processAction (AddIP2Bans ip reason expiring) = do
|
|
422 |
(Just ci) <- gets clientIndex
|
|
423 |
rc <- gets removedClients
|
|
424 |
when (not $ ci `Set.member` rc)
|
|
425 |
$ processAction $ ModifyServerInfo (\s -> s{bans = BanByIP ip reason expiring : bans s})
|
|
426 |
|
|
427 |
processAction CheckBanned = do
|
|
428 |
clTime <- client's connectTime
|
|
429 |
clNick <- client's nick
|
|
430 |
clHost <- client's host
|
|
431 |
si <- gets serverInfo
|
|
432 |
let validBans = filter (checkNotExpired clTime) $ bans si
|
|
433 |
let ban = L.find (checkBan clHost clNick) $ validBans
|
|
434 |
when (isJust ban) $
|
|
435 |
mapM_ processAction [
|
|
436 |
ModifyServerInfo (\s -> s{bans = validBans})
|
|
437 |
, ByeClient (getBanReason $ fromJust ban)
|
|
438 |
]
|
|
439 |
where
|
|
440 |
checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0
|
|
441 |
checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0
|
|
442 |
checkBan ip _ (BanByIP bip _ _) = bip == ip
|
|
443 |
checkBan _ n (BanByNick bn _ _) = bn == n
|
|
444 |
getBanReason (BanByIP _ msg _) = msg
|
|
445 |
getBanReason (BanByNick _ msg _) = msg
|
|
446 |
|
|
447 |
processAction PingAll = do
|
|
448 |
rnc <- gets roomsClients
|
|
449 |
io (allClientsM rnc) >>= mapM_ (kickTimeouted rnc)
|
|
450 |
cis <- io $ allClientsM rnc
|
|
451 |
chans <- io $ mapM (client'sM rnc sendChan) cis
|
|
452 |
io $ mapM_ (modifyClient rnc (\cl -> cl{pingsQueue = pingsQueue cl + 1})) cis
|
|
453 |
processAction $ AnswerClients chans ["PING"]
|
|
454 |
where
|
|
455 |
kickTimeouted rnc ci = do
|
|
456 |
pq <- io $ client'sM rnc pingsQueue ci
|
|
457 |
when (pq > 0) $
|
|
458 |
withStateT (\as -> as{clientIndex = Just ci}) $
|
|
459 |
processAction (ByeClient "Ping timeout")
|
|
460 |
|
|
461 |
|
|
462 |
processAction StatsAction = do
|
|
463 |
rnc <- gets roomsClients
|
|
464 |
si <- gets serverInfo
|
|
465 |
(roomsNum, clientsNum) <- io $ withRoomsAndClients rnc st
|
|
466 |
io $ writeChan (dbQueries si) $ SendStats clientsNum (roomsNum - 1)
|
|
467 |
where
|
|
468 |
st irnc = (length $ allRooms irnc, length $ allClients irnc)
|
|
469 |
|
|
470 |
processAction (RestartServer force) = do
|
|
471 |
if force then do
|
|
472 |
throw RestartException
|
|
473 |
else
|
|
474 |
processAction $ ModifyServerInfo (\s -> s{restartPending=True})
|
|
475 |
|
|
476 |
processAction SaveReplay = do
|
|
477 |
ri <- clientRoomA
|
|
478 |
rnc <- gets roomsClients
|
|
479 |
io $ do
|
|
480 |
r <- room'sM rnc id ri
|
|
481 |
saveReplay r
|