Choose first unused color for added team (addresses issue 431) + other small changes
authorunc0rr
Sun, 28 Oct 2012 23:43:56 +0400
changeset 7862 bd76ca40db68
parent 7860 a90936219ffa
child 7863 34fc0644d231
Choose first unused color for added team (addresses issue #431) + other small changes
gameServer/CoreTypes.hs
gameServer/HWProtoInRoomState.hs
gameServer/HWProtoLobbyState.hs
gameServer/Utils.hs
--- a/gameServer/CoreTypes.hs	Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/CoreTypes.hs	Sun Oct 28 23:43:56 2012 +0400
@@ -142,7 +142,6 @@
         latestReleaseVersion :: Word16,
         earliestCompatibleVersion :: Word16,
         listenPort :: PortNumber,
-        --nextRoomID :: Int,
         dbHost :: B.ByteString,
         dbName :: B.ByteString,
         dbLogin :: B.ByteString,
@@ -162,11 +161,10 @@
     ServerInfo
         True
         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
-        "<font color=yellow><h3 align=center>Hedgewars 0.9.17 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
-        41
-        43 -- 0.9.18
+        "<font color=yellow><h3 align=center>Hedgewars 0.9.18 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
+        43 -- latestReleaseVersion
+        41 -- earliestCompatibleVersion
         46631
-        --0
         ""
         ""
         ""
--- a/gameServer/HWProtoInRoomState.hs	Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/HWProtoInRoomState.hs	Sun Oct 28 23:43:56 2012 +0400
@@ -3,7 +3,7 @@
 
 import qualified Data.Map as Map
 import Data.Sequence((|>))
-import Data.List
+import Data.List as L
 import Data.Maybe
 import qualified Data.ByteString.Char8 as B
 import Control.Monad
@@ -52,6 +52,13 @@
         clNick <- clientNick
         clChan <- thisClientChans
         othChans <- roomOthersChans
+        roomChans <- roomClientsChans
+        cl <- thisClient
+        teamColor <-
+            if clientProto cl < 42 then 
+                return color
+                else
+                liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
         return $
             if not . null . drop (maxTeams rm - 1) $ teams rm then
                 [Warning "too many teams"]
@@ -64,16 +71,16 @@
             else if isRestrictedTeams rm then
                 [Warning "restricted"]
             else
-                [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r]}),
-                ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just color}),
+                [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r teamColor]}),
+                ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just teamColor}),
                 AnswerClients clChan ["TEAM_ACCEPTED", tName],
-                AnswerClients othChans $ teamToNet $ newTeam ci clNick rm,
-                AnswerClients othChans ["TEAM_COLOR", tName, color]
+                AnswerClients othChans $ teamToNet $ newTeam ci clNick rm teamColor,
+                AnswerClients roomChans ["TEAM_COLOR", tName, teamColor]
                 ]
         where
         canAddNumber r = 48 - (sum . map hhnum $ teams r)
         findTeam = find (\t -> tName == teamname t) . teams
-        newTeam ci clNick r = TeamInfo ci clNick tName color grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
+        newTeam ci clNick r tColor = TeamInfo ci clNick tName tColor grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
         dif = readInt_ difStr
         hhsList [] = []
         hhsList [_] = error "Hedgehogs list with odd elements number"
--- a/gameServer/HWProtoLobbyState.hs	Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/HWProtoLobbyState.hs	Sun Oct 28 23:43:56 2012 +0400
@@ -53,7 +53,7 @@
             [
                 AddRoom rName roomPassword
                 , AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl]
-                , ModifyClient (\cl -> cl{isMaster = True, isReady = True})
+                , ModifyClient (\c -> c{isMaster = True, isReady = True})
                 , ModifyRoom (\r -> r{readyPlayers = 1})
             ]
 
--- a/gameServer/Utils.hs	Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/Utils.hs	Sun Oct 28 23:43:56 2012 +0400
@@ -88,6 +88,8 @@
             , (40, "0.9.17-dev")
             , (41, "0.9.17")
             , (42, "0.9.18-dev")
+            , (43, "0.9.18")
+            , (44, "0.9.19-dev")
             ]
 
 askFromConsole :: B.ByteString -> IO B.ByteString