Fix build, and also make protocol a bit more consistent and flexible (only in docs though, to be implemented)
authorunc0rr
Thu, 26 Jun 2014 21:43:36 +0400
changeset 10342 16122539d2ea
parent 10341 22e441db6343
child 10343 fe9853dea6c4
Fix build, and also make protocol a bit more consistent and flexible (only in docs though, to be implemented)
doc/protocol.txt
gameServer/HWProtoLobbyState.hs
--- a/doc/protocol.txt	Thu Jun 26 00:48:44 2014 +0400
+++ b/doc/protocol.txt	Thu Jun 26 21:43:36 2014 +0400
@@ -18,14 +18,15 @@
     'E' + <текст>   сообщение об ошибке
     ','             /skip
     't' + №         /taunt №
-    'g' + <nick>    teams of user 'nick' are controlled again (synced msg)
+    'f' + <team>    'team' is uncontrolled
+    'g' + <team>    'team' is controlled again (synced msg)
 
 фронтенд клиенту:
     'e' + <команда> выполнить "/<команда>"
     'T' + {L,N,D}   тип игры (локальная, сетевая, просмотр демо)
     'W' + <текст>   сообщение о нефатальной ошибке
     'F' + <team>    команда team вылетела в сетевой игре
-    'G' + <nick>    user 'nick' is back (unsynced msg)
+    'G' + <team>    'team' is back (unsynced msg)
     'o'             stop syncing, game over!
 
 Клиент фронтенду:
--- a/gameServer/HWProtoLobbyState.hs	Thu Jun 26 00:48:44 2014 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Thu Jun 26 21:43:36 2014 +0400
@@ -50,6 +50,7 @@
 
 handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
     (_, irnc) <- ask
+
     let ris = allRooms irnc
     cl <- thisClient
     let maybeRI = find (\ri -> roomName == name (irnc `room` ri)) ris
@@ -61,7 +62,11 @@
     let owner = find isMaster jRoomClients
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
-    let hasTeamsInGame = (isJust $ gameInfo jRoom) && (or . map (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom)
+    let clTeams =
+            if (isJust $ gameInfo jRoom) then
+                map teamname . filter (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom 
+                else
+                []
     return $
         if isNothing maybeRI then
             [Warning $ loc "No such room"]
@@ -88,7 +93,7 @@
             ++ answerTeams cl jRoom
             ++ watchRound cl jRoom chans
             ++ [AnswerClients [sendChan cl] ["CHAT", "[greeting]", greeting jRoom] | greeting jRoom /= ""]
-            ++ if hasTeamsInGame then ["EM", toEngineMsg $ 'G' `B.cons` nick cl] else []
+            ++ map (\t -> AnswerClients chans ["EM", toEngineMsg $ 'G' `B.cons` t]) clTeams
 
         where
         sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $