author | Periklis Ntanasis <pntanasis@gmail.com> |
Wed, 11 Dec 2013 17:58:32 +0200 | |
changeset 9781 | 5eb7c3778045 |
parent 9753 | 9579596cf471 |
child 9787 | 0da6ba2f1f93 |
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 |
||
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
|
4 |
import Data.Maybe |
1804 | 5 |
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
|
6 |
import Control.Monad.Reader |
9303 | 7 |
import qualified Data.ByteString.Char8 as B |
1804 | 8 |
-------------------------------------- |
9 |
import CoreTypes |
|
10 |
import Actions |
|
11 |
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
|
12 |
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
|
13 |
import RoomsAndClients |
6068 | 14 |
import EngineInteraction |
1804 | 15 |
|
4932 | 16 |
|
4989 | 17 |
handleCmd_lobby :: CmdHandler |
1804 | 18 |
|
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
|
19 |
|
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_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
|
21 |
(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
|
22 |
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
|
23 |
rooms <- allRoomInfos |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
24 |
let roomsInfoList = concatMap (\r -> roomInfo (clientProto cl) (maybeNick . liftM (client irnc) $ masterID r) r) . filter (\r -> (roomProto r == clientProto 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
|
25 |
return [AnswerClients [sendChan cl] ("ROOMS" : roomsInfoList rooms)] |
3501 | 26 |
|
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
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
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
|
31 |
|
4932 | 32 |
handleCmd_lobby ["CREATE_ROOM", rName, roomPassword] |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8369
diff
changeset
|
33 |
| illegalName rName = return [Warning $ loc "Illegal room name"] |
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
|
34 |
| 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
|
35 |
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
|
36 |
cl <- thisClient |
4932 | 37 |
return $ if isJust $ find (\r -> rName == name r) rs 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
|
38 |
[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
|
39 |
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
|
40 |
[ |
7775 | 41 |
AddRoom rName roomPassword |
42 |
, AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl] |
|
9109
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9035
diff
changeset
|
43 |
, ModifyClient (\c -> c{isMaster = True, isReady = True, isJoinedMidGame = False}) |
7775 | 44 |
, ModifyRoom (\r -> r{readyPlayers = 1}) |
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
|
45 |
] |
1804 | 46 |
|
3536 | 47 |
|
4932 | 48 |
handleCmd_lobby ["CREATE_ROOM", rName] = |
49 |
handleCmd_lobby ["CREATE_ROOM", rName, ""] |
|
3536 | 50 |
|
1862 | 51 |
|
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
|
52 |
handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do |
4932 | 53 |
(_, irnc) <- 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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
let jRoom = irnc `room` jRI |
5931 | 59 |
let sameProto = clientProto cl == roomProto jRoom |
4597
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
60 |
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
|
61 |
let nicks = map nick jRoomClients |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
62 |
let owner = find isMaster jRoomClients |
4597
31e042ab870c
Finally a solution for excess lazyness when working with unsafeThaw'ed arrays
unc0rr
parents:
4595
diff
changeset
|
63 |
let chans = map sendChan (cl : jRoomClients) |
7537
833a0c34fafc
Room bans. They're more simple, than the global ones: if you ban someone, he is banned by ip in this room for the rest of the room lifetime. Not tested.
unc0rr
parents:
7321
diff
changeset
|
64 |
let isBanned = host cl `elem` roomBansList 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
|
65 |
return $ |
9729
6a3640c4f4b7
Show "incompatible version" message instead of "no such room" on try to join room with another protocol version
unc0rr
parents:
9702
diff
changeset
|
66 |
if isNothing maybeRI then |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8369
diff
changeset
|
67 |
[Warning $ loc "No such room"] |
9729
6a3640c4f4b7
Show "incompatible version" message instead of "no such room" on try to join room with another protocol version
unc0rr
parents:
9702
diff
changeset
|
68 |
else if not sameProto then |
6a3640c4f4b7
Show "incompatible version" message instead of "no such room" on try to join room with another protocol version
unc0rr
parents:
9702
diff
changeset
|
69 |
[Warning $ loc "Room version incompatible to your hedgewars version"] |
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
|
70 |
else if isRestrictedJoins jRoom then |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8369
diff
changeset
|
71 |
[Warning $ loc "Joining restricted"] |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
72 |
else if isRegisteredOnly jRoom && (B.null . webPassword $ cl) && not (isAdministrator cl) then |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8369
diff
changeset
|
73 |
[Warning $ loc "Registered users only"] |
7537
833a0c34fafc
Room bans. They're more simple, than the global ones: if you ban someone, he is banned by ip in this room for the rest of the room lifetime. Not tested.
unc0rr
parents:
7321
diff
changeset
|
74 |
else if isBanned then |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8369
diff
changeset
|
75 |
[Warning $ loc "You are banned in this 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
|
76 |
else if roomPassword /= password jRoom then |
6912
831416764d2d
Allow LIST command while in room to not annoy old frontends (0.9.17 or less) with warnings
unc0rr
parents:
6541
diff
changeset
|
77 |
[NoticeMessage WrongPassword] |
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
|
78 |
else |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
79 |
( |
7682 | 80 |
MoveToRoom jRI |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
81 |
: ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom}) |
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
82 |
: (AnswerClients [sendChan cl] $ "JOINED" : nicks) |
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
83 |
: AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] |
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
84 |
: [AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner] |
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
85 |
) |
8235 | 86 |
++ (if clientProto cl < 38 then map (readynessMessage cl) jRoomClients else [sendStateFlags cl jRoomClients]) |
9109
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9035
diff
changeset
|
87 |
++ answerFullConfig cl jRoom |
8897
d6c310c65c91
- Revert server workaround over desync from r98e2dbdda8c0
unc0rr
parents:
8519
diff
changeset
|
88 |
++ answerTeams cl jRoom |
d6c310c65c91
- Revert server workaround over desync from r98e2dbdda8c0
unc0rr
parents:
8519
diff
changeset
|
89 |
++ watchRound cl jRoom chans |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9729
diff
changeset
|
90 |
++ [] |
1804 | 91 |
|
4587 | 92 |
where |
8235 | 93 |
readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c] |
94 |
sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $ |
|
95 |
[f "+r" ready, f "-r" unready, f "+g" ingame, f "-g" inroomlobby] |
|
96 |
where |
|
97 |
(ready, unready) = partition isReady clients |
|
98 |
(ingame, inroomlobby) = partition isInGame clients |
|
99 |
f fl lst = ["CLIENT_FLAGS" : fl : map nick lst | not $ null lst] |
|
3536 | 100 |
|
9109
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9035
diff
changeset
|
101 |
-- get config from gameInfo if possible, otherwise from room |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9035
diff
changeset
|
102 |
answerFullConfig cl jRoom = let f r g = (if isJust $ gameInfo jRoom then g . fromJust . gameInfo else r) jRoom |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9035
diff
changeset
|
103 |
in answerFullConfigParams cl (f mapParams giMapParams) (f params giParams) |
4587 | 104 |
|
5996
2c72fe81dd37
Convert boolean variable + a bunch of fields which make sense only while game is going on into Maybe + structure
unc0rr
parents:
5931
diff
changeset
|
105 |
answerTeams cl jRoom = let f = if isJust $ gameInfo jRoom then teamsAtStart . fromJust . gameInfo else teams in answerAllTeams cl $ f jRoom |
4591 | 106 |
|
8237 | 107 |
watchRound cl jRoom chans = if isNothing $ gameInfo jRoom then |
2867
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 |
9304
3f4c3fc146c2
Fix spectator desync in rare conditions (there was team which left during its turn, and last command with timestamp from it was '+')
unc0rr
parents:
9303
diff
changeset
|
110 |
AnswerClients [sendChan cl] ["RUN_GAME"] |
3f4c3fc146c2
Fix spectator desync in rare conditions (there was team which left during its turn, and last command with timestamp from it was '+')
unc0rr
parents:
9303
diff
changeset
|
111 |
: AnswerClients chans ["CLIENT_FLAGS", "+g", nick cl] |
3f4c3fc146c2
Fix spectator desync in rare conditions (there was team which left during its turn, and last command with timestamp from it was '+')
unc0rr
parents:
9303
diff
changeset
|
112 |
: ModifyClient (\c -> c{isInGame = True}) |
9381 | 113 |
: [AnswerClients [sendChan cl] $ "EM" : toEngineMsg "e$spectate 1" : (reverse . roundMsgs . fromJust . gameInfo $ jRoom)] |
1813 | 114 |
|
3536 | 115 |
|
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
|
116 |
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
|
117 |
handleCmd_lobby ["JOIN_ROOM", roomName, ""] |
4568 | 118 |
|
1804 | 119 |
|
4616 | 120 |
handleCmd_lobby ["FOLLOW", asknick] = do |
121 |
(_, rnc) <- ask |
|
8486
9a65baafd7d7
Send JOINING message in response to FOLLOW. Actual join may still fail due to room restrictions. Not tested.
unc0rr
parents:
8403
diff
changeset
|
122 |
clChan <- liftM sendChan thisClient |
4616 | 123 |
ci <- clientByNick asknick |
124 |
let ri = clientRoom rnc $ fromJust ci |
|
8486
9a65baafd7d7
Send JOINING message in response to FOLLOW. Actual join may still fail due to room restrictions. Not tested.
unc0rr
parents:
8403
diff
changeset
|
125 |
let roomName = name $ room rnc ri |
5931 | 126 |
if isNothing ci || ri == lobbyId then |
4616 | 127 |
return [] |
128 |
else |
|
8486
9a65baafd7d7
Send JOINING message in response to FOLLOW. Actual join may still fail due to room restrictions. Not tested.
unc0rr
parents:
8403
diff
changeset
|
129 |
liftM ((:) (AnswerClients [clChan] ["JOINING", roomName])) $ handleCmd_lobby ["JOIN_ROOM", roomName] |
1862 | 130 |
|
9035
e84d42a4311c
'/rnd' command. Pass it a (possibly empty) list of items.
unc0rr
parents:
8897
diff
changeset
|
131 |
|
e84d42a4311c
'/rnd' command. Pass it a (possibly empty) list of items.
unc0rr
parents:
8897
diff
changeset
|
132 |
handleCmd_lobby ("RND":rs) = do |
e84d42a4311c
'/rnd' command. Pass it a (possibly empty) list of items.
unc0rr
parents:
8897
diff
changeset
|
133 |
c <- liftM sendChan thisClient |
e84d42a4311c
'/rnd' command. Pass it a (possibly empty) list of items.
unc0rr
parents:
8897
diff
changeset
|
134 |
return [Random [c] rs] |
e84d42a4311c
'/rnd' command. Pass it a (possibly empty) list of items.
unc0rr
parents:
8897
diff
changeset
|
135 |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
136 |
--------------------------- |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2408
diff
changeset
|
137 |
-- Administrator's stuff -- |
1862 | 138 |
|
4618 | 139 |
handleCmd_lobby ["KICK", kickNick] = do |
140 |
(ci, _) <- ask |
|
141 |
cl <- thisClient |
|
142 |
kickId <- clientByNick kickNick |
|
143 |
return [KickClient $ fromJust kickId | isAdministrator cl && isJust kickId && fromJust kickId /= ci] |
|
1866 | 144 |
|
4909 | 145 |
|
8156 | 146 |
handleCmd_lobby ["BAN", banNick, reason, duration] = do |
4909 | 147 |
(ci, _) <- ask |
148 |
cl <- thisClient |
|
149 |
banId <- clientByNick banNick |
|
8156 | 150 |
return [BanClient (readInt_ duration) reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci] |
7321
57bd4f201401
- Try sending remove message in 'finally' as a last resort
unc0rr
parents:
6912
diff
changeset
|
151 |
|
5426
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
152 |
handleCmd_lobby ["BANIP", ip, reason, duration] = do |
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
153 |
cl <- thisClient |
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
154 |
return [BanIP ip (readInt_ duration) reason | isAdministrator cl] |
7321
57bd4f201401
- Try sending remove message in 'finally' as a last resort
unc0rr
parents:
6912
diff
changeset
|
155 |
|
8154 | 156 |
handleCmd_lobby ["BANNICK", n, reason, duration] = do |
157 |
cl <- thisClient |
|
158 |
return [BanNick n (readInt_ duration) reason | isAdministrator cl] |
|
159 |
||
5426
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
160 |
handleCmd_lobby ["BANLIST"] = do |
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
161 |
cl <- thisClient |
109e9b5761c2
Implement command for banning by ip and a command for bans list
unc0rr
parents:
5209
diff
changeset
|
162 |
return [BanList | isAdministrator cl] |
1804 | 163 |
|
3283 | 164 |
|
7748 | 165 |
handleCmd_lobby ["UNBAN", entry] = do |
166 |
cl <- thisClient |
|
167 |
return [Unban entry | isAdministrator cl] |
|
168 |
||
169 |
||
4620 | 170 |
handleCmd_lobby ["SET_SERVER_VAR", "MOTD_NEW", newMessage] = do |
171 |
cl <- thisClient |
|
172 |
return [ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator cl] |
|
1925 | 173 |
|
4620 | 174 |
handleCmd_lobby ["SET_SERVER_VAR", "MOTD_OLD", newMessage] = do |
175 |
cl <- thisClient |
|
176 |
return [ModifyServerInfo (\si -> si{serverMessageForOldVersions = newMessage}) | isAdministrator cl] |
|
3260
b44b88908758
Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents:
2961
diff
changeset
|
177 |
|
4620 | 178 |
handleCmd_lobby ["SET_SERVER_VAR", "LATEST_PROTO", protoNum] = do |
179 |
cl <- thisClient |
|
180 |
return [ModifyServerInfo (\si -> si{latestReleaseVersion = readNum}) | isAdministrator cl && readNum > 0] |
|
3260
b44b88908758
Allow to set motd for old client versions (not used yet, as server needs some refactoring)
unc0rr
parents:
2961
diff
changeset
|
181 |
where |
5030
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4989
diff
changeset
|
182 |
readNum = readInt_ protoNum |
7321
57bd4f201401
- Try sending remove message in 'finally' as a last resort
unc0rr
parents:
6912
diff
changeset
|
183 |
|
4620 | 184 |
handleCmd_lobby ["GET_SERVER_VAR"] = do |
185 |
cl <- thisClient |
|
186 |
return [SendServerVars | isAdministrator cl] |
|
3283 | 187 |
|
4620 | 188 |
handleCmd_lobby ["CLEAR_ACCOUNTS_CACHE"] = do |
189 |
cl <- thisClient |
|
190 |
return [ClearAccountsCache | isAdministrator cl] |
|
3283 | 191 |
|
5209
f7a610e2ef5f
On restart command close server socket and spawn new server, keep running until last client quits
unc0rr
parents:
5093
diff
changeset
|
192 |
handleCmd_lobby ["RESTART_SERVER"] = do |
4914 | 193 |
cl <- thisClient |
7537
833a0c34fafc
Room bans. They're more simple, than the global ones: if you ban someone, he is banned by ip in this room for the rest of the room lifetime. Not tested.
unc0rr
parents:
7321
diff
changeset
|
194 |
return [RestartServer | isAdministrator cl] |
4914 | 195 |
|
8403
fbc6e7602e05
- Allow server admins to use DELEGATE even when not room owner
unc0rr
parents:
8401
diff
changeset
|
196 |
handleCmd_lobby ["STATS"] = do |
fbc6e7602e05
- Allow server admins to use DELEGATE even when not room owner
unc0rr
parents:
8401
diff
changeset
|
197 |
cl <- thisClient |
fbc6e7602e05
- Allow server admins to use DELEGATE even when not room owner
unc0rr
parents:
8401
diff
changeset
|
198 |
return [Stats | isAdministrator cl] |
3283 | 199 |
|
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 |
handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"] |