author | unc0rr |
Wed, 15 Oct 2008 17:04:46 +0000 | |
changeset 1363 | bcd4cb0245f0 |
parent 1354 | a8dcdeb88a43 |
child 1368 | a734715a777a |
permissions | -rw-r--r-- |
890 | 1 |
module HWProto where |
2 |
||
3 |
import IO |
|
896 | 4 |
import Data.List |
894 | 5 |
import Data.Word |
890 | 6 |
import Miscutils |
1320 | 7 |
import Maybe |
1317 | 8 |
import qualified Data.Map as Map |
890 | 9 |
|
1331
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
10 |
teamToNet team = ["ADD_TEAM", teamname team, teamgrave team, teamfort team, show $ difficulty team] ++ hhsInfo |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
11 |
where |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
12 |
hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
13 |
|
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
14 |
answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] |
1317 | 15 |
answerNotMaster = [(clientOnly, ["ERROR", "You cannot configure room parameters"])] |
1327 | 16 |
answerBadParam = [(clientOnly, ["ERROR", "Bad parameter"])] |
1309 | 17 |
answerQuit = [(clientOnly, ["off"])] |
1327 | 18 |
answerAbandoned = [(othersInRoom, ["BYE"])] |
1309 | 19 |
answerQuitInform nick = [(othersInRoom, ["LEFT", nick])] |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
20 |
answerNickChosen = [(clientOnly, ["ERROR", "The nick already chosen"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
21 |
answerNickChooseAnother = [(clientOnly, ["WARNING", "Choose another nick"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
22 |
answerNick nick = [(clientOnly, ["NICK", nick])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
23 |
answerProtocolKnown = [(clientOnly, ["ERROR", "Protocol number already known"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
24 |
answerBadInput = [(clientOnly, ["ERROR", "Bad input"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
25 |
answerProto protoNum = [(clientOnly, ["PROTO", show protoNum])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
26 |
answerRoomsList list = [(clientOnly, ["ROOMS"] ++ list)] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
27 |
answerRoomExists = [(clientOnly, ["WARNING", "There's already a room with that name"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
28 |
answerJoined nick = [(sameRoom, ["JOINED", nick])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
29 |
answerNoRoom = [(clientOnly, ["WARNING", "There's no room with that name"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
30 |
answerWrongPassword = [(clientOnly, ["WARNING", "Wrong password"])] |
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
31 |
answerChatString nick msg = [(othersInRoom, ["CHAT_STRING", nick, msg])] |
1317 | 32 |
answerConfigParam paramName paramStrs = [(othersInRoom, "CONFIG_PARAM" : paramName : paramStrs)] |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
33 |
answerFullConfig room = map toAnswer (Map.toList $ params room) ++ [(clientOnly, ["MAP", gamemap room])] |
1317 | 34 |
where |
1321 | 35 |
toAnswer (paramName, paramStrs) = |
1317 | 36 |
(clientOnly, "CONFIG_PARAM" : paramName : paramStrs) |
1328 | 37 |
answerCantAdd = [(clientOnly, ["WARNING", "Too many teams or hedgehogs, or same name team"])] |
1325 | 38 |
answerTeamAccepted team = [(clientOnly, ["TEAM_ACCEPTED", teamname team])] |
1331
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
39 |
answerAddTeam team = [(othersInRoom, teamToNet team)] |
1327 | 40 |
answerHHNum teamName hhNumber = [(othersInRoom, ["HH_NUM", teamName, show hhNumber])] |
1328 | 41 |
answerRemoveTeam teamName = [(othersInRoom, ["REMOVE_TEAM", teamName])] |
1329 | 42 |
answerNotOwner = [(clientOnly, ["ERROR", "You do not own this team"])] |
1330 | 43 |
answerTeamColor teamName newColor = [(othersInRoom, ["TEAM_COLOR", teamName, newColor])] |
1331
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
44 |
answerAllTeams room = concatMap toAnswer (teams room) |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
45 |
where |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
46 |
toAnswer team = |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
47 |
[(clientOnly, teamToNet team), |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
48 |
(clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]), |
ae291cfd617a
Send teams info to newly connected client (has a bug with team sequence, need to discover)
unc0rr
parents:
1330
diff
changeset
|
49 |
(clientOnly, ["HH_NUM", teamname team, show $ hhnum team])] |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
50 |
answerMap mapName = [(othersInRoom, ["MAP", mapName])] |
1338 | 51 |
answerRunGame = [(sameRoom, ["RUN_GAME"])] |
1307 | 52 |
|
1082 | 53 |
-- Main state-independent cmd handler |
54 |
handleCmd :: CmdHandler |
|
55 |
handleCmd client _ rooms ("QUIT":xs) = |
|
56 |
if null (room client) then |
|
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
57 |
(noChangeClients, noChangeRooms, answerQuit) |
1082 | 58 |
else if isMaster client then |
1327 | 59 |
(noChangeClients, removeRoom (room client), answerQuit ++ answerAbandoned) -- core disconnects clients on ROOMABANDONED answer |
1082 | 60 |
else |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1350
diff
changeset
|
61 |
(noChangeClients, modifyRoom clRoom{teams = othersTeams}, answerQuit ++ (answerQuitInform $ nick client) ++ answerRemoveClientTeams) |
1334
b58afaadf7ae
Send team removal message to others in room when client disconnects
unc0rr
parents:
1333
diff
changeset
|
62 |
where |
b58afaadf7ae
Send team removal message to others in room when client disconnects
unc0rr
parents:
1333
diff
changeset
|
63 |
clRoom = roomByName (room client) rooms |
1335
c795cbc752c1
Small optimization (use partition instead of two filters with opposite predicates)
unc0rr
parents:
1334
diff
changeset
|
64 |
answerRemoveClientTeams = map (\tn -> (othersInRoom, ["REMOVE_TEAM", teamname tn])) clientTeams |
c795cbc752c1
Small optimization (use partition instead of two filters with opposite predicates)
unc0rr
parents:
1334
diff
changeset
|
65 |
(clientTeams, othersTeams) = partition (\t -> teamowner t == nick client) $ teams clRoom |
895 | 66 |
|
1307 | 67 |
|
1082 | 68 |
-- check state and call state-dependent commmand handlers |
69 |
handleCmd client clients rooms cmd = |
|
70 |
if null (nick client) || protocol client == 0 then |
|
71 |
handleCmd_noInfo client clients rooms cmd |
|
72 |
else if null (room client) then |
|
73 |
handleCmd_noRoom client clients rooms cmd |
|
74 |
else |
|
75 |
handleCmd_inRoom client clients rooms cmd |
|
76 |
||
1307 | 77 |
|
1082 | 78 |
-- 'no info' state - need to get protocol number and nickname |
79 |
handleCmd_noInfo :: CmdHandler |
|
80 |
handleCmd_noInfo client clients _ ["NICK", newNick] = |
|
894 | 81 |
if not . null $ nick client then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
82 |
(noChangeClients, noChangeRooms, answerNickChosen) |
894 | 83 |
else if haveSameNick then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
84 |
(noChangeClients, noChangeRooms, answerNickChooseAnother) |
894 | 85 |
else |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
86 |
(modifyClient client{nick = newNick}, noChangeRooms, answerNick newNick) |
894 | 87 |
where |
1320 | 88 |
haveSameNick = isJust $ find (\cl -> newNick == nick cl) clients |
894 | 89 |
|
1082 | 90 |
handleCmd_noInfo client _ _ ["PROTO", protoNum] = |
894 | 91 |
if protocol client > 0 then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
92 |
(noChangeClients, noChangeRooms, answerProtocolKnown) |
894 | 93 |
else if parsedProto == 0 then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
94 |
(noChangeClients, noChangeRooms, answerBadInput) |
894 | 95 |
else |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
96 |
(modifyClient client{protocol = parsedProto}, noChangeRooms, answerProto parsedProto) |
894 | 97 |
where |
98 |
parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16) |
|
99 |
||
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
100 |
handleCmd_noInfo _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd) |
894 | 101 |
|
1307 | 102 |
|
894 | 103 |
-- 'noRoom' clients state command handlers |
1082 | 104 |
handleCmd_noRoom :: CmdHandler |
105 |
handleCmd_noRoom client _ rooms ["LIST"] = |
|
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
106 |
(noChangeClients, noChangeRooms, answerRoomsList $ map name rooms) |
903 | 107 |
|
1082 | 108 |
handleCmd_noRoom client _ rooms ["CREATE", newRoom, roomPassword] = |
895 | 109 |
if haveSameRoom then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
110 |
(noChangeClients, noChangeRooms, answerRoomExists) |
895 | 111 |
else |
1350 | 112 |
(modifyClient client{room = newRoom, isMaster = True}, addRoom createRoom{name = newRoom, password = roomPassword, roomProto = (protocol client)}, answerJoined $ nick client) |
895 | 113 |
where |
1320 | 114 |
haveSameRoom = isJust $ find (\room -> newRoom == name room) rooms |
895 | 115 |
|
1082 | 116 |
handleCmd_noRoom client clients rooms ["CREATE", newRoom] = |
117 |
handleCmd_noRoom client clients rooms ["CREATE", newRoom, ""] |
|
118 |
||
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
119 |
handleCmd_noRoom client clients rooms ["JOIN", roomName, roomPassword] = |
902 | 120 |
if noSuchRoom then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
121 |
(noChangeClients, noChangeRooms, answerNoRoom) |
1321 | 122 |
else if roomPassword /= password clRoom then |
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
123 |
(noChangeClients, noChangeRooms, answerWrongPassword) |
895 | 124 |
else |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1351
diff
changeset
|
125 |
(modifyClient client{room = roomName}, noChangeRooms, answerNicks ++ (answerJoined $ nick client) ++ answerFullConfig clRoom ++ answerAllTeams clRoom) |
895 | 126 |
where |
1320 | 127 |
noSuchRoom = isNothing $ find (\room -> roomName == name room) rooms |
1308
d5dcd6cfa5e2
Fix another server failure (when second client in room disconnects)
unc0rr
parents:
1307
diff
changeset
|
128 |
answerNicks = [(clientOnly, ["JOINED"] ++ (map nick $ filter (\ci -> room ci == roomName) clients))] |
1321 | 129 |
clRoom = roomByName roomName rooms |
895 | 130 |
|
1082 | 131 |
handleCmd_noRoom client clients rooms ["JOIN", roomName] = |
132 |
handleCmd_noRoom client clients rooms ["JOIN", roomName, ""] |
|
894 | 133 |
|
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
134 |
handleCmd_noRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd) |
895 | 135 |
|
1307 | 136 |
|
897 | 137 |
-- 'inRoom' clients state command handlers |
1082 | 138 |
handleCmd_inRoom :: CmdHandler |
1322
c624b04699fb
Fix protocol implementation to conform documentation
unc0rr
parents:
1321
diff
changeset
|
139 |
handleCmd_inRoom client _ _ ["CHAT_STRING", msg] = |
1317 | 140 |
(noChangeClients, noChangeRooms, answerChatString (nick client) msg) |
897 | 141 |
|
1327 | 142 |
handleCmd_inRoom client _ rooms ("CONFIG_PARAM" : paramName : paramStrs) = |
1317 | 143 |
if isMaster client then |
1322
c624b04699fb
Fix protocol implementation to conform documentation
unc0rr
parents:
1321
diff
changeset
|
144 |
(noChangeClients, modifyRoom clRoom{params = Map.insert paramName paramStrs (params clRoom)}, answerConfigParam paramName paramStrs) |
1317 | 145 |
else |
146 |
(noChangeClients, noChangeRooms, answerNotMaster) |
|
1321 | 147 |
where |
148 |
clRoom = roomByName (room client) rooms |
|
149 |
||
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
150 |
handleCmd_inRoom client _ rooms ["MAP", mapName] = |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
151 |
if isMaster client then |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
152 |
(noChangeClients, modifyRoom clRoom{gamemap = mapName}, answerMap mapName) |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
153 |
else |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
154 |
(noChangeClients, noChangeRooms, answerNotMaster) |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
155 |
where |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
156 |
clRoom = roomByName (room client) rooms |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1332
diff
changeset
|
157 |
|
1327 | 158 |
handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo) |
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
159 |
| length hhsInfo == 16 = |
1328 | 160 |
if length (teams clRoom) == 6 || canAddNumber <= 0 || isJust findTeam then |
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
161 |
(noChangeClients, noChangeRooms, answerCantAdd) |
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
162 |
else |
1336
4e88eccbe7f6
Fix team colors mismatch on some conditions (just synchronize them when team is added)
unc0rr
parents:
1335
diff
changeset
|
163 |
(noChangeClients, modifyRoom clRoom{teams = teams clRoom ++ [newTeam]}, answerTeamAccepted newTeam ++ answerAddTeam newTeam ++ answerTeamColor name color) |
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
164 |
where |
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
165 |
clRoom = roomByName (room client) rooms |
1329 | 166 |
newTeam = (TeamInfo (nick client) name color grave fort difficulty newTeamHHNum (hhsList hhsInfo)) |
1328 | 167 |
findTeam = find (\t -> name == teamname t) $ teams clRoom |
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
168 |
difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int) |
1325 | 169 |
hhsList [] = [] |
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
170 |
hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs |
1327 | 171 |
canAddNumber = 18 - (sum . map hhnum $ teams clRoom) |
172 |
newTeamHHNum = min 4 canAddNumber |
|
173 |
||
174 |
handleCmd_inRoom client _ rooms ["HH_NUM", teamName, numberStr] = |
|
175 |
if not $ isMaster client then |
|
176 |
(noChangeClients, noChangeRooms, answerNotMaster) |
|
177 |
else |
|
1329 | 178 |
if hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) then |
1327 | 179 |
(noChangeClients, noChangeRooms, answerBadParam) |
180 |
else |
|
181 |
(noChangeClients, modifyRoom $ modifyTeam clRoom team{hhnum = hhNumber}, answerHHNum teamName hhNumber) |
|
182 |
where |
|
183 |
hhNumber = fromMaybe 0 (maybeRead numberStr :: Maybe Int) |
|
184 |
noSuchTeam = isNothing findTeam |
|
185 |
team = fromJust findTeam |
|
186 |
findTeam = find (\t -> teamName == teamname t) $ teams clRoom |
|
187 |
clRoom = roomByName (room client) rooms |
|
188 |
canAddNumber = 18 - (sum . map hhnum $ teams clRoom) |
|
1323
d166f9069c2b
Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept)
unc0rr
parents:
1322
diff
changeset
|
189 |
|
1330 | 190 |
handleCmd_inRoom client _ rooms ["TEAM_COLOR", teamName, newColor] = |
191 |
if not $ isMaster client then |
|
192 |
(noChangeClients, noChangeRooms, answerNotMaster) |
|
193 |
else |
|
194 |
(noChangeClients, modifyRoom $ modifyTeam clRoom team{teamcolor = newColor}, answerTeamColor teamName newColor) |
|
195 |
where |
|
196 |
noSuchTeam = isNothing findTeam |
|
197 |
team = fromJust findTeam |
|
198 |
findTeam = find (\t -> teamName == teamname t) $ teams clRoom |
|
199 |
clRoom = roomByName (room client) rooms |
|
200 |
||
1328 | 201 |
handleCmd_inRoom client _ rooms ["REMOVE_TEAM", teamName] = |
1329 | 202 |
if noSuchTeam then |
203 |
(noChangeClients, noChangeRooms, answerBadParam) |
|
1328 | 204 |
else |
1329 | 205 |
if not $ nick client == teamowner team then |
206 |
(noChangeClients, noChangeRooms, answerNotOwner) |
|
1328 | 207 |
else |
208 |
(noChangeClients, modifyRoom clRoom{teams = filter (\t -> teamName /= teamname t) $ teams clRoom}, answerRemoveTeam teamName) |
|
209 |
where |
|
210 |
noSuchTeam = isNothing findTeam |
|
211 |
team = fromJust findTeam |
|
212 |
findTeam = find (\t -> teamName == teamname t) $ teams clRoom |
|
213 |
clRoom = roomByName (room client) rooms |
|
1083 | 214 |
|
1350 | 215 |
handleCmd_inRoom client _ rooms ["READY"] = |
1338 | 216 |
if not $ isMaster client then |
217 |
(noChangeClients, noChangeRooms, answerNotMaster) |
|
218 |
else |
|
1350 | 219 |
(noChangeClients, modifyRoom clRoom{gameinprogress = True}, answerRunGame) |
220 |
where |
|
221 |
clRoom = roomByName (room client) rooms |
|
1338 | 222 |
|
1345
73119de7d3be
Server erases teams list after round finish, so everything should be okay now
unc0rr
parents:
1344
diff
changeset
|
223 |
handleCmd_inRoom client _ rooms ["ROUNDFINISHED"] = |
73119de7d3be
Server erases teams list after round finish, so everything should be okay now
unc0rr
parents:
1344
diff
changeset
|
224 |
if isMaster client then |
1350 | 225 |
(noChangeClients, modifyRoom clRoom{teams = [], gameinprogress = False}, []) |
1345
73119de7d3be
Server erases teams list after round finish, so everything should be okay now
unc0rr
parents:
1344
diff
changeset
|
226 |
else |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1338
diff
changeset
|
227 |
(noChangeClients, noChangeRooms, []) |
1345
73119de7d3be
Server erases teams list after round finish, so everything should be okay now
unc0rr
parents:
1344
diff
changeset
|
228 |
where |
73119de7d3be
Server erases teams list after round finish, so everything should be okay now
unc0rr
parents:
1344
diff
changeset
|
229 |
clRoom = roomByName (room client) rooms |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1338
diff
changeset
|
230 |
|
1338 | 231 |
handleCmd_inRoom client _ _ ["GAMEMSG", msg] = |
232 |
(noChangeClients, noChangeRooms, [(othersInRoom, ["GAMEMSG", msg])]) |
|
233 |
||
1304
05cebf68ebd8
Start refactoring standalone server (prepare to change protocol)
unc0rr
parents:
1302
diff
changeset
|
234 |
handleCmd_inRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd) |