Skip to content

Commit 2c712c7

Browse files
committed
Fix build, and also make protocol a bit more consistent and flexible (only in docs though, to be implemented)
1 parent 1d0b3a2 commit 2c712c7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

doc/protocol.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
'E' + <текст> сообщение об ошибке
1919
',' /skip
2020
't' + № /taunt №
21-
'g' + <nick> teams of user 'nick' are controlled again (synced msg)
21+
'f' + <team> 'team' is uncontrolled
22+
'g' + <team> 'team' is controlled again (synced msg)
2223

2324
фронтенд клиенту:
2425
'e' + <команда> выполнить "/<команда>"
2526
'T' + {L,N,D} тип игры (локальная, сетевая, просмотр демо)
2627
'W' + <текст> сообщение о нефатальной ошибке
2728
'F' + <team> команда team вылетела в сетевой игре
28-
'G' + <nick> user 'nick' is back (unsynced msg)
29+
'G' + <team> 'team' is back (unsynced msg)
2930
'o' stop syncing, game over!
3031

3132
Клиент фронтенду:

gameServer/HWProtoLobbyState.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ handleCmd_lobby ["CREATE_ROOM", rName] =
5050

5151
handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
5252
(_, irnc) <- ask
53+
5354
let ris = allRooms irnc
5455
cl <- thisClient
5556
let maybeRI = find (\ri -> roomName == name (irnc `room` ri)) ris
@@ -61,7 +62,11 @@ handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
6162
let owner = find isMaster jRoomClients
6263
let chans = map sendChan (cl : jRoomClients)
6364
let isBanned = host cl `elem` roomBansList jRoom
64-
let hasTeamsInGame = (isJust $ gameInfo jRoom) && (or . map (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom)
65+
let clTeams =
66+
if (isJust $ gameInfo jRoom) then
67+
map teamname . filter (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom
68+
else
69+
[]
6570
return $
6671
if isNothing maybeRI then
6772
[Warning $ loc "No such room"]
@@ -88,7 +93,7 @@ handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
8893
++ answerTeams cl jRoom
8994
++ watchRound cl jRoom chans
9095
++ [AnswerClients [sendChan cl] ["CHAT", "[greeting]", greeting jRoom] | greeting jRoom /= ""]
91-
++ if hasTeamsInGame then ["EM", toEngineMsg $ 'G' `B.cons` nick cl] else []
96+
++ map (\t -> AnswerClients chans ["EM", toEngineMsg $ 'G' `B.cons` t]) clTeams
9297

9398
where
9499
sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $

0 commit comments

Comments
 (0)