Inform engine if player is back after being disconnected
authorunc0rr
Mon, 23 Jun 2014 23:50:08 +0400
changeset 10338 9558b0380779
parent 10337 05a5762ab12c
child 10339 a1168c400c90
Inform engine if player is back after being disconnected
doc/protocol.txt
gameServer/HWProtoLobbyState.hs
--- a/doc/protocol.txt	Mon Jun 23 22:22:29 2014 +0400
+++ b/doc/protocol.txt	Mon Jun 23 23:50:08 2014 +0400
@@ -18,12 +18,14 @@
     'E' + <текст>   сообщение об ошибке
     ','             /skip
     't' + №         /taunt №
+    'g' + <nick>    teams of user 'nick' are controlled again (synced msg)
 
 фронтенд клиенту:
     'e' + <команда> выполнить "/<команда>"
     'T' + {L,N,D}   тип игры (локальная, сетевая, просмотр демо)
     'W' + <текст>   сообщение о нефатальной ошибке
     'F' + <team>    команда team вылетела в сетевой игре
+    'G' + <nick>    user 'nick' is back (unsynced msg)
     'o'             stop syncing, game over!
 
 Клиент фронтенду:
--- a/gameServer/HWProtoLobbyState.hs	Mon Jun 23 22:22:29 2014 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Mon Jun 23 23:50:08 2014 +0400
@@ -61,6 +61,7 @@
     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)
     return $
         if isNothing maybeRI then
             [Warning $ loc "No such room"]
@@ -87,6 +88,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 []
 
         where
         sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $